def post(self): if lindenip.inrange(os.environ['REMOTE_ADDR']) != 'Production': self.error(403) elif self.request.headers['X-SecondLife-Shard'] != 'Production': logging.warning("Attempt while on beta grid %s" % (self.request.headers['X-SecondLife-Shard'])) self.response.set_status(305) else: av=self.request.headers['X-SecondLife-Owner-Key'] objectkey=self.request.headers['X-SecondLife-Object-Key'] sim_id = self.request.headers['X-SecondLife-Region'] logging.info('Bought items request from %s in sim %s' % (av, sim_id)) #if paid_items == '': # paid_items = '0' #if tags == '': # tags = 'all' #tags = tags.split('|') body = self.request.body # Use a query parameter to keep track of the last key of the last # batch, to know where to start the next batch. last_key_str = self.request.get('start') last_version_str = self.request.get('last_version') last_version = int(last_version_str) current_version = int(model.GenericStorage_GetOrPutDefault('TextureTime', '0')) # normal work mode, lets do check and send texture result ='' logging.info ('Versions different (DB:%s,Vendor:%s) Starting to send update...' % (current_version, last_version_str)) if not last_key_str: last_key = 0 result ='version\n%s\n' % current_version logging.info ('no last_key, send from start') else: last_key=int(last_key_str) result ='continue\n%s\n' % current_version logging.info ('last_key was: %s' % last_key_str) query = Purchases.all() query.filter('item_reciver =', av) entities = query.fetch(21,last_key) count = 0 more = False for texture in entities: count = count + 1 if count < 21: logging.info('%s:%d' % (texture.freebie_name,texture.freebie_texture_update)) result=result + texture.freebie_name +"\n"+texture.freebie_texture_key+"\n" else: last_key=last_key+20 result=result + ("startwith\n%d" % (last_key)) more = True logging.info ('More texture availabe, request next time from %d' % (last_key)) if more == False: logging.info ('Sending finished now') result = result + "end\n" self.response.out.write(result)
def post(self): if lindenip.inrange(os.environ['REMOTE_ADDR']) != 'Production': self.error(403) elif self.request.headers['X-SecondLife-Shard'] != 'Production': logging.warning("Attempt while on beta grid %s" % (self.request.headers['X-SecondLife-Shard'])) self.response.set_status(305) else: av=self.request.headers['X-SecondLife-Owner-Key'] if not distributors.distributor_authorized(av): # function needs to be changed to distributors.authorized_designer as soon as the database for that is fully functioning self.error(402) else: objectkey=self.request.headers['X-SecondLife-Object-Key'] public = self.request.get('Public') version = self.request.get('tv') current_version = model.GenericStorage_GetOrPutDefault('TextureTime', '0') logging.info("Texture request from vendor with version %s, db at version %s" % (version, current_version)) if version: if current_version != version: self.response.out.write('UPDATE:%s' % current_version) else: self.response.out.write('CURRENT')
def post(self): if lindenip.inrange(os.environ['REMOTE_ADDR']) != 'Production': self.error(403) elif self.request.headers['X-SecondLife-Shard'] != 'Production': logging.warning("Attempt while on beta grid %s" % (self.request.headers['X-SecondLife-Shard'])) self.response.set_status(305) elif not self.request.headers['X-SecondLife-Owner-Key'] in model.adminkeys: self.error(403) else: t=int(time.time()) serverkey= self.request.headers['X-SecondLife-Object-Key'] logging.info('Texture update started from texture server %s at %d' % (serverkey, t)) # Setting texture time to negative time to signalize texure update is in progress currentVersion = int(model.GenericStorage_GetOrPutDefault('TextureTime', '0')) if currentVersion < 0: if -currentVersion + updateTimeout < t: logging.warning('Texture update timestamp was outdated, allowing texture update (Old timestamp: %d)' % currentVersion) else: logging.warning('Texture update requested from texture server %s at %d, but already in progress' % (serverkey, t)) self.response.out.write('Update already in progress, try again later' ) return logging.info('Texture update started from texture server %s at %d' % (serverkey, t)) model.GenericStorage_Store('TextureTime', '-%d' % t) self.response.out.write('Timestamp:%d' % t )
def post(self): if lindenip.inrange(os.environ['REMOTE_ADDR']) != 'Production': self.error(403) elif self.request.headers['X-SecondLife-Shard'] != 'Production': logging.warning("Attempt while on beta grid %s" % (self.request.headers['X-SecondLife-Shard'])) self.response.set_status(305) else: av=self.request.headers['X-SecondLife-Owner-Key'] # if not distributors.Distributor_authorized(av): #Really needs to be changed??? function needs to be changed to distributors.authorized_designer as soon as the database for that is fully functioning # self.error(402) # else: objectkey=self.request.headers['X-SecondLife-Object-Key'] sim_id = self.request.headers['X-SecondLife-Region'] logging.info('Gift Texture request from %s in sim %s' % (objectkey, sim_id)) body = self.request.body # Use a query parameter to keep track of the last key of the last # batch, to know where to start the next batch. last_key_str = self.request.get('start') last_version_str = self.request.get('last_version') last_version = int(last_version_str) current_version = int(model.GenericStorage_GetOrPutDefault('TextureTime', '0')) if current_version < 0: # system updating at the moment logging.info ('System in update mode, inform the client') self.response.out.write('Updating') else: # normal work mode, lets do check and send texture result ='' if not last_version_str: # no last time given so we can use the stored time last_version_str = '0' last_version = 0 logging.info ('no last_version, send update') else: last_version = int(last_version_str) logging.info ('last_version (%s)' % last_version_str) if current_version == last_version: logging.info ('Versions are identic, no action needed') self.response.out.write('CURRENT') else: logging.info ('Versions different (DB:%s,Vendor:%s) Starting to send update...' % (current_version, last_version_str)) if not last_key_str: last_key = 0 result ='version\n%s\n' % current_version logging.info ('no last_key, send from start') else: last_key=int(last_key_str) result ='continue\n%s\n' % current_version logging.info ('last_key was: %s' % last_key_str) query = FreebieItem.all() query.filter('freebie_texture_update >', 0) entities = query.fetch(21,last_key) count = 0 more = False for texture in entities: count = count + 1 if count < 21: logging.info('%s:%d' % (texture.freebie_name,texture.freebie_texture_update)) result=result + texture.freebie_name +"\n"+texture.freebie_texture_key+"\n" result=result + "%s\n" % texture.baseprice else: last_key=last_key+20 result=result + ("startwith\n%d" % (last_key)) more = True logging.info ('More texture availabe, request next time from %d' % (last_key)) if more == False: logging.info ('Sending finished now') result = result + "end\n" self.response.out.write(result)