Example #1
0
 def get(self):
     logging.info('CRON UpdateCount')
     query = FreebieItem.all().fetch(1000)
     for record in query:
         count_token = 'item_count_%s' % record.freebie_name
         count = memcache.get(count_token)
         if count is not None:
             if int(count) > 1:
                 db.run_in_transaction(UpdateRecord, record.key(), count_token)
                 logging.info('CRON: Count info for %s  updated with %s new requests' % (record.freebie_name, count))
     logging.info('CRON UpdateCount: Finished')
Example #2
0
 def get(self):
     logging.info('CRON UpdateCount')
     query = FreebieItem.all().fetch(1000)
     for record in query:
         count_token = 'item_count_%s' % record.freebie_name
         count = memcache.get(count_token)
         if count is not None:
             if int(count) > 1:
                 db.run_in_transaction(UpdateRecord, record.key(),
                                       count_token)
                 logging.info(
                     'CRON: Count info for %s  updated with %s new requests'
                     % (record.freebie_name, count))
     logging.info('CRON UpdateCount: Finished')
Example #3
0
 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)
Example #4
0
    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)