예제 #1
0
    def post(self):
        #check linden IP  and allowed avs
        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 distributors.Distributor_authorized(self.request.headers['X-SecondLife-Owner-Key']):
#            logging.info("Illegal attempt to request an item from %s, box %s located in %s at %s" % (self.request.headers['X-SecondLife-Owner-Name'], self.request.headers['X-SecondLife-Object-Name'], self.request.headers['X-SecondLife-Region'], self.request.headers['X-SecondLife-Local-Position']))
#            self.error(403)
        elif not db.WRITE_CAPABILITY.is_enabled():
            self.response.set_status(503)
            self.response.headders['Retry-After'] = 120
            logging.info("Told that the db was down for maintenance to %s, box %s located in %s at %s" % (self.request.headers['X-SecondLife-Owner-Name'], self.request.headers['X-SecondLife-Object-Name'], self.request.headers['X-SecondLife-Region'], self.request.headers['X-SecondLife-Local-Position']))
            self.response.out.write('Currently down for maintenance')
        else:
            #populate a dictionary with what we've been given in post
            #should be newline-delimited, token=value
            lines = self.request.body.split('\n')
            params = {}
            for line in lines:
                params[line.split('=')[0]] = line.split('=')[1]

            try:
                name = params['objname']
                item = tools.get_item(name, True)
                if item is None:
                    #could not find item to look up its deliverer.  return an error
                    logging.error('Error, Paid item %s not found. Requested by %s using %s.' % (name, self.request.headers['X-SecondLife-Owner-Name'], self.request.headers['X-SecondLife-Object-Name']))
                    self.error(403)
                    return
                name_version = "%s - %s" % (name, item['version'])
                rcpt = self.request.headers['X-SecondLife-Owner-Key']
                paid = int(params['paid'])
                baseprice = int(item['baseprice'])
                if paid >= baseprice:
                    pass
                else:

                            logging.error('Rejecting request: Wrong price by %s, gift vendor %s located in %s at %s. Item:%s Item Price:%s Price Paid:%s' % 
                              (self.request.headers['X-SecondLife-Owner-Name'],
                               self.request.headers['X-SecondLife-Object-Name'],
                               self.request.headers['X-SecondLife-Region'],
                               self.request.headers['X-SecondLife-Local-Position'],
                               name,
                               baseprice,
                               paid
                               ))
                            self.error(403)
                            return  
                #need to record record here
                record = Purchases(purchaser = rcpt, item = name, seller = self.request.headers['X-SecondLife-Owner-Key'], item_reciver = 'gift request', loc = '%s %s' % (self.request.headers['X-SecondLife-Region'], self.request.headers['X-SecondLife-Local-Position']), vender_name = self.request.headers['X-SecondLife-Object-Name'], amount_paid = paid)
                record.put()
                #have the vendor transfer the money
                self.response.out.write('pay|%s|%s|%s|%s|%s' % (moneyRcpt, paid, rcpt, name, record.key().id()))#do we need all of this?
            except KeyError:
                logging.error('Key error for paid Post gift vendor  %s, queue entry: %s|%s   %s' % (item['giver'], rcpt, name_version, sys.exc_info()))
                self.error(403)
예제 #2
0
    def get(self):
        if lindenip.inrange(os.environ['REMOTE_ADDR']) != 'Production':
            self.error(403)
#        elif not distributors.Distributor_authorized(self.request.headers['X-SecondLife-Owner-Key']):
#            logging.info("Illegal attempt to request an item from %s, box %s located in %s at %s" % (self.request.headers['X-SecondLife-Owner-Name'], self.request.headers['X-SecondLife-Object-Name'], self.request.headers['X-SecondLife-Region'], self.request.headers['X-SecondLife-Local-Position']))
#            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:
            #should be newline-delimited, token=value
#            lines = self.request.body.split('\n')
#            params = {}
#            for line in lines:
#                params[line.split('=')[0]] = line.split('=')[1]
            try:
                recordID = int(self.request.get('id'))
                record = Purchases.get_by_id(recordID)
                if record is None:
                    #could not find item to look up its deliverer.  return an error
                    logging.error('Error, Paid record %s not found. Requested by %s using %s.' % (recordID, self.request.headers['X-SecondLife-Owner-Name'], self.request.headers['X-SecondLife-Object-Name']))
                    self.error(404)
                    return
                elif record.item_reciver == self.request.headers['X-SecondLife-Owner-Key']:
                    rcpt = record.item_reciver
                    name = record.item
                    self.response.out.write(tools.httpin_delivery(self, rcpt, name, record.key().id()))
                else:
                    logging.error('Error, Paid record %s found but requested by %s using %s and it is set for %s.' % (recordID, self.request.headers['X-SecondLife-Owner-Name'], self.request.headers['X-SecondLife-Object-Name'], record.item_reciver))
                    self.error(403)
            except KeyError:
                logging.error('Key error for paid PUT gift receive vendor %s, queue entry: %s|%s   %s' % (self.request.headers['X-SecondLife-Object-Key'], rcpt, name, sys.exc_info()))
                self.error(403)        
예제 #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"]
            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)
예제 #4
0
    def put(self):
        #check linden IP  and allowed avs
        if lindenip.inrange(os.environ['REMOTE_ADDR']) != 'Production':
            self.error(403)


#        elif not distributors.Distributor_authorized(self.request.headers['X-SecondLife-Owner-Key']):
#            logging.info("Illegal attempt to request an item from %s, box %s located in %s at %s" % (self.request.headers['X-SecondLife-Owner-Name'], self.request.headers['X-SecondLife-Object-Name'], self.request.headers['X-SecondLife-Region'], self.request.headers['X-SecondLife-Local-Position']))
#            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 db.WRITE_CAPABILITY.is_enabled():
            self.response.set_status(503)
            self.response.headders['Retry-After'] = 120
            logging.info(
                "Told that the db was down for maintenance to %s, box %s located in %s at %s"
                % (self.request.headers['X-SecondLife-Owner-Name'],
                   self.request.headers['X-SecondLife-Object-Name'],
                   self.request.headers['X-SecondLife-Region'],
                   self.request.headers['X-SecondLife-Local-Position']))
            self.response.out.write('Currently down for maintenance')
        else:
            #populate a dictionary with what we've been given in post
            #should be newline-delimited, token=value
            lines = self.request.body.split('\n')
            params = {}
            for line in lines:
                params[line.split('=')[0]] = line.split('=')[1]

            try:
                recordID = int(params['id'])
                record = Purchases.get_by_id(recordID)
                if record is None:
                    #could not find item to look up its deliverer.  return an error
                    logging.error(
                        'Error, Paid record %s not found. Requested by %s using %s.'
                        % (recordID,
                           self.request.headers['X-SecondLife-Owner-Name'],
                           self.request.headers['X-SecondLife-Object-Name']))
                    self.error(403)
                    return
                #else:
                record.item_reciver = 'gift'
                record.accounted = "0"
                record.put()
                self.response.out.write('confirmed|||%s' % (recordID))
            except KeyError:
                logging.error(
                    'Key error for paid PUT gift vendor %s, queue entry: %s|%s   %s'
                    % (self.request.headers['X-SecondLife-Object-Key'],
                       record.item_reciver, recordID, sys.exc_info()))
                self.error(403)
예제 #5
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']
            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)
예제 #6
0
    def post(self):
        #check linden IP  and allowed avs`
        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 distributors.Contributor_authorized(
                self.request.headers['X-SecondLife-Owner-Key']):
            logging.info(
                "Illegal attempt to request a list from %s, box %s located in %s at %s"
                % (self.request.headers['X-SecondLife-Owner-Name'],
                   self.request.headers['X-SecondLife-Object-Name'],
                   self.request.headers['X-SecondLife-Region'],
                   self.request.headers['X-SecondLife-Local-Position']))
            self.error(403)
        elif not db.WRITE_CAPABILITY.is_enabled():
            self.response.set_status(503)
            self.response.headders['Retry-After'] = 120
            logging.info(
                "Told that the db was down for maintenance to %s, box %s located in %s at %s"
                % (self.request.headers['X-SecondLife-Owner-Name'],
                   self.request.headers['X-SecondLife-Object-Name'],
                   self.request.headers['X-SecondLife-Region'],
                   self.request.headers['X-SecondLife-Local-Position']))
            self.response.out.write('Currently down for maintenance')
        else:
            #populate a dictionary with what we've been given in post
            #should be newline-delimited, token=value
            lines = self.request.body.split('\n')
            params = {}
            for line in lines:
                params[line.split('=')[0]] = line.split('=')[1]

            try:
                rcpt = str(params['rcpt'])
                query = Purchases.all()
                query.filter('item_reciver =', rcpt)
                items = []
                for item in query:
                    items = items + [item.item]
                result = "%s\n%s" % (rcpt, "\n".join(set(items)))
                logging.info('Sent paid items list for %s' % rcpt)
                self.response.out.write(result)
            except KeyError:
                logging.error(
                    'Key error for paid resender list vendor %s, queue entry: %s|%s   %s'
                    % (self.request.headers['X-SecondLife-Object-Key'], rcpt,
                       lines, sys.exc_info()))
                self.error(403)
예제 #7
0
    def get(self):
        if lindenip.inrange(os.environ['REMOTE_ADDR']) != 'Production':
            self.error(403)


#        elif not distributors.Distributor_authorized(self.request.headers['X-SecondLife-Owner-Key']):
#            logging.info("Illegal attempt to request an item from %s, box %s located in %s at %s" % (self.request.headers['X-SecondLife-Owner-Name'], self.request.headers['X-SecondLife-Object-Name'], self.request.headers['X-SecondLife-Region'], self.request.headers['X-SecondLife-Local-Position']))
#            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:
            #should be newline-delimited, token=value
            #            lines = self.request.body.split('\n')
            #            params = {}
            #            for line in lines:
            #                params[line.split('=')[0]] = line.split('=')[1]
            try:
                recordID = int(self.request.get('id'))
                record = Purchases.get_by_id(recordID)
                if record is None:
                    #could not find item to look up its deliverer.  return an error
                    logging.error(
                        'Error, Paid record %s not found. Requested by %s using %s.'
                        % (recordID,
                           self.request.headers['X-SecondLife-Owner-Name'],
                           self.request.headers['X-SecondLife-Object-Name']))
                    self.error(404)
                    return
                elif record.item_reciver == self.request.headers[
                        'X-SecondLife-Owner-Key']:
                    rcpt = record.item_reciver
                    name = record.item
                    self.response.out.write(
                        tools.httpin_delivery(self, rcpt, name,
                                              record.key().id()))
                else:
                    logging.error(
                        'Error, Paid record %s found but requested by %s using %s and it is set for %s.'
                        % (recordID,
                           self.request.headers['X-SecondLife-Owner-Name'],
                           self.request.headers['X-SecondLife-Object-Name'],
                           record.item_reciver))
                    self.error(403)
            except KeyError:
                logging.error(
                    'Key error for paid PUT gift receive vendor %s, queue entry: %s|%s   %s'
                    % (self.request.headers['X-SecondLife-Object-Key'], rcpt,
                       name, sys.exc_info()))
                self.error(403)
예제 #8
0
    def put(self):
        #check linden IP  and allowed avs
        if lindenip.inrange(os.environ['REMOTE_ADDR']) != 'Production':
            self.error(403)
#        elif not distributors.Distributor_authorized(self.request.headers['X-SecondLife-Owner-Key']):
#            logging.info("Illegal attempt to request an item from %s, box %s located in %s at %s" % (self.request.headers['X-SecondLife-Owner-Name'], self.request.headers['X-SecondLife-Object-Name'], self.request.headers['X-SecondLife-Region'], self.request.headers['X-SecondLife-Local-Position']))
#            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 db.WRITE_CAPABILITY.is_enabled():
            self.response.set_status(503)
            self.response.headders['Retry-After'] = 120
            logging.info("Told that the db was down for maintenance to %s, box %s located in %s at %s" % (self.request.headers['X-SecondLife-Owner-Name'], self.request.headers['X-SecondLife-Object-Name'], self.request.headers['X-SecondLife-Region'], self.request.headers['X-SecondLife-Local-Position']))
            self.response.out.write('Currently down for maintenance')
        else:
            #populate a dictionary with what we've been given in post
            #should be newline-delimited, token=value
            lines = self.request.body.split('\n')
            params = {}
            for line in lines:
                params[line.split('=')[0]] = line.split('=')[1]
            try:
                recordID = int(params['id'])
                record = Purchases.get_by_id(recordID)
                if record is None:
                    #could not find item to look up its deliverer.  return an error
                    logging.error('Error, Paid record %s not found. Requested by %s using %s.' % (recordID, self.request.headers['X-SecondLife-Owner-Name'], self.request.headers['X-SecondLife-Object-Name']))
                    self.error(404)
                    return
                elif record.item_reciver == 'gift':
                    record.item_reciver = self.request.headers['X-SecondLife-Owner-Key']
                    record.put()
                    logging.debug('Paid record %s updated to show rcpt is %s.' % (recordID, self.request.headers['X-SecondLife-Owner-Name']))
                    rcpt = record.item_reciver
                    name = record.item
                    self.response.out.write('rcpt set|||%s' % (recordID))
                else:
                    logging.error('Error, Paid record %s not found. Requested by %s using %s.' % (recordID, self.request.headers['X-SecondLife-Owner-Name'], self.request.headers['X-SecondLife-Object-Name']))
                    self.error(403)
            except KeyError:
                logging.error('Key error for paid PUT gift receive vendor %s, queue entry: %s|%s   %s' % (self.request.headers['X-SecondLife-Object-Key'], rcpt, recordID, sys.exc_info()))
                self.error(403)
예제 #9
0
    def post(self):
        #check linden IP  and allowed avs`
        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 distributors.Contributor_authorized(self.request.headers['X-SecondLife-Owner-Key']):
            logging.info("Illegal attempt to request a list from %s, box %s located in %s at %s" % (self.request.headers['X-SecondLife-Owner-Name'], self.request.headers['X-SecondLife-Object-Name'], self.request.headers['X-SecondLife-Region'], self.request.headers['X-SecondLife-Local-Position']))
            self.error(403)
        elif not db.WRITE_CAPABILITY.is_enabled():
            self.response.set_status(503)
            self.response.headders['Retry-After'] = 120
            logging.info("Told that the db was down for maintenance to %s, box %s located in %s at %s" % (self.request.headers['X-SecondLife-Owner-Name'], self.request.headers['X-SecondLife-Object-Name'], self.request.headers['X-SecondLife-Region'], self.request.headers['X-SecondLife-Local-Position']))
            self.response.out.write('Currently down for maintenance')
        else:
            #populate a dictionary with what we've been given in post
            #should be newline-delimited, token=value
            lines = self.request.body.split('\n')
            params = {}
            for line in lines:
                params[line.split('=')[0]] = line.split('=')[1]

            try:
                rcpt = str(params['rcpt'])
                query = Purchases.all()
                query.filter('item_reciver =', rcpt)
                items = []
                for item in query:
                    items= items + [item.item]
                result = "%s\n%s" % (rcpt, "\n".join(set(items)))
                logging.info ('Sent paid items list for %s' % rcpt)
                self.response.out.write(result)
            except KeyError:
                logging.error('Key error for paid resender list vendor %s, queue entry: %s|%s   %s' % (self.request.headers['X-SecondLife-Object-Key'], rcpt, lines, sys.exc_info()))
                self.error(403)
예제 #10
0
파일: cron.py 프로젝트: lkalif/collardata
 def get(self):
     if not db.WRITE_CAPABILITY.is_enabled():
         self.response.set_status(503)
         self.response.headders['Retry-After'] = 120
         logging.info("Told that the db was down for maintenance")
         self.response.out.write('Currently down for maintenance')
     else:
         t=int(time.time()) - 7200;
         logging.info('CRON AccountNewRecords: totaling funds for after %d' % t)
         dispersal = Dispersals()
         commissions_total = 0
         designer_total = 0
         maintainers_total = 0
         total = 0
         maintainers = AppSettings.get_or_insert("maintainers", value="00000000-0000-0000-0000-000000000000|0").value.split("|")
         people_to_pay = []
         query = Purchases.gql("WHERE accounted = :1",  "0")
         for record in query:
             logging.info('CRON: %s|%s' % (record.key().id(), record.seller))
             total += record.amount_paid
             token = 'Distributor_%s' % record.seller
             cacheditem = memcache.get(token)
             if cacheditem is None:
                 dist = Distributor.gql("WHERE avkey = :1", record.seller).get()
                 dist_info = {"max_discount":dist.max_discount, "commission":dist.commission}
                 memcache.set(token, yaml.safe_dump(dist_info))
             else:
                 #pull the item's details out of the yaml'd dict
                 dist_info = yaml.safe_load(cacheditem)
             if dist_info['commission'] > 0:
                 commission = record.paid_amount*dist_info['commission']/100
                 commissions_total += commission
                 stoken = '%s_seller' % (record.seller)
                 commission_total = commission + getattr(dispersal, stoken, 0)
                 setattr(dispersal, stoken, commission_total)
                 people_to_pay.append(stoken)
             name = record.item
             item = tools.get_item(name, True)
             if item is None:
                 logging.error('Error, Paid item %s not found. Requested by %s using %s.' % (name, self.request.headers['X-SecondLife-Owner-Name'], self.request.headers['X-SecondLife-Object-Name']))
             if item['designer_cut'] > 0:
                 cut = record.paid_amount*item['designer_cut']/100
                 designer_total += cut
                 dtoken = '%s_designer' % (item['designer'])
                 cut_total = cut + getattr(dispersal, dtoken, 0)
                 setattr(dispersal, dtoken, cut_total)
                 people_to_pay.append(dtoken)
         for maintainer, amount in zip(maintainers[::2], maintainers[1::2]):
             cut = total*int(amount)/100
             maintainers_total += cut
             mtoken = '%s_maintainer' % (maintainer)
             setattr(dispersal, mtoken, cut)
             people_to_pay.append(mtoken)
         if query.count(1) > 0:
             if total >= (maintainers_total + designer_total + commissions_total):
                 setattr(dispersal, 'commissions_total', commissions_total)
                 setattr(dispersal, 'designers_total', designer_total)
                 setattr(dispersal, 'maintainers_total', maintainers_total)
                 setattr(dispersal, 'dispersal_total', (maintainers_total + designer_total + commissions_total))
                 setattr(dispersal, 'total', total)
                 setattr(dispersal, 'people_to_pay', "\n".join(people_to_pay))
                 dispersal.put()
                 logging.info('CRON AccountNewRecords: saved')
                 #add right url
                 taskqueue.add(url='/paiddist/disperse?id=%s' % (dispersal.key().id()), headers={}, queue_name='Disperse', method='PUT')
                 for record in query:
                     record.accounted = "1"
                     record.put()
             else:
                 logging.error("CRON AccountNewRecords: total dispersal %s is greater than total paid %s" % (maintainers_total + designer_total + commissions_total, total))
                 redirecturl = "not needed?"
                 alarm.SendAlarm('Dispersal', t, True, "total dispersal %s is greater than total paid %s" % (maintainers_total + designer_total + commissions_total, total), redirecturl)
                 self.error(500)
         else:
             logging.info('CRON AccountNewRecords: No records')
         logging.info('CRON AccountNewRecords: Finished')
예제 #11
0
    def post(self):
        #check linden IP  and allowed avs
        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 distributors.Contributor_authorized(self.request.headers['X-SecondLife-Owner-Key']):
            logging.info("Illegal attempt to request redeliver from %s, box %s located in %s at %s" % (self.request.headers['X-SecondLife-Owner-Name'], self.request.headers['X-SecondLife-Object-Name'], self.request.headers['X-SecondLife-Region'], self.request.headers['X-SecondLife-Local-Position']))
            self.error(403)
#don't need this for redelivery
#        elif not db.WRITE_CAPABILITY.is_enabled():
#            self.response.set_status(503)
#            self.response.headders['Retry-After'] = 120
#            logging.info("Told that the db was down for maintenance to %s, box %s located in %s at %s" % (self.request.headers['X-SecondLife-Owner-Name'], self.request.headers['X-SecondLife-Object-Name'], self.request.headers['X-SecondLife-Region'], self.request.headers['X-SecondLife-Local-Position']))
#            self.response.out.write('Currently down for maintenance')
        else:
            #populate a dictionary with what we've been given in post
            #should be newline-delimited, token=value
            lines = self.request.body.split('\n')
            params = {}
            for line in lines:
                params[line.split('=')[0]] = line.split('=')[1]

            try:
                rcpt = str(params['rcpt'])
                item_name = params['objname']
                query = Purchases.all(keys_only=True)
                query.filter('item_reciver =', rcpt)
                query.filter('item =', item_name)
                if query.count(1):
                    self.response.out.write(tools.httpin_delivery(self, rcpt, item_name, ""))
#                    token = 'paid_item_%s' % item_name
#                    cacheditem = memcache.get(token)
#                    if cacheditem is None:
#                        paiditem = FreebieItem.gql("WHERE freebie_name = :1", item_name).get()
#                        if paiditem is None:
#                            #could not find item to look up its deliverer.  return an error
#                            logging.error('Error, Paid item %s not found yet was found before. Requested by %s using %s.' % (item_name, self.request.headers['X-SecondLife-Owner-Name'], self.request.headers['X-SecondLife-Object-Name']))
#                            self.error(503)
#                            return
#                        else:
#                            item = {"name":paiditem.freebie_name, "version":paiditem.freebie_version, "giver":paiditem.freebie_giver, "givers":paiditem.givers, "giver":paiditem.freebie_giver, "baseprice":paiditem.baseprice}
#                            memcache.set(token, yaml.safe_dump(item))
#                    else:
#                        #pull the item's details out of the yaml'd dict
#                        item = yaml.safe_load(cacheditem)
#                    name_version = "%s - %s" % (item_name, item['version'])
#                    if item['givers'] == []:
#                        logging.error('Error, Paid item %s does not have http urls.' % (name))
#                        self.error(503)
#                        return
#                    urls = item['givers']
#                    #need to add a way to rotate the urls
#                    url_token = 'url_%s' % item_name
#                    url_num = memcache.incr(url_token, initial_value=0)
#                    url_num = url_num % ((len(urls)/2))
#                    
#                    count_token = 'item_count_%s' % item_name
#                    memcache.incr(count_token, initial_value=0)
#                    #need to send itme here
#                    result = urlfetch.fetch(urls[url_num*2-1], method="POST", payload="%s|%s" % (name_version, rcpt) , headers={}, deadline = 10)
#                    if result.content == "sent":
#                        self.response.out.write('sent|%s|%s' % (rcpt, name_version))#do we need all of this?
#                    else:
#                        url_num = memcache.incr(url_token, initial_value=0)
#                        url_num = url_num % ((len(urls)/2))
#                        #need to send itme here
#                        result = urlfetch.fetch(urls[url_num*2-1], method="POST", payload="%s|%s" % (name_version, rcpt) , headers={}, deadline = 10)
#                        if result.content == "sent":
#                            self.response.out.write('sent|%s|%s' % (rcpt, name_version))#do we need all of this?
#                        else:
#                            logging.error('Error, Paid item %s did not get sent. Status %s Message from vendor: %s' % (name_version, result.status_code, result.content))
#                            self.error(503)
                else:
                    logging.error('Error, %s has no record of paid item %s yet redelvier requested it.' % (rcpt, item_name))
                    self.error(404)
            except KeyError:
                logging.error('Key error for paid redeliver vendor %s, queue entry: %s|%s   %s' % (self.request.headers['X-SecondLife-Object-Key'], rcpt, item_name, sys.exc_info()))
                self.error(403)                
예제 #12
0
    def post(self):
        #check linden IP  and allowed avs
        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 distributors.Distributor_authorized(self.request.headers['X-SecondLife-Owner-Key']):
            logging.warning("Illegal attempt to request an item from %s, box %s located in %s at %s" % (self.request.headers['X-SecondLife-Owner-Name'], self.request.headers['X-SecondLife-Object-Name'], self.request.headers['X-SecondLife-Region'], self.request.headers['X-SecondLife-Local-Position']))
            self.error(403)
        elif not db.WRITE_CAPABILITY.is_enabled():
            self.response.set_status(503)
            self.response.headders['Retry-After'] = 120
            logging.info("Told that the db was down for maintenance to %s, box %s located in %s at %s" % (self.request.headers['X-SecondLife-Owner-Name'], self.request.headers['X-SecondLife-Object-Name'], self.request.headers['X-SecondLife-Region'], self.request.headers['X-SecondLife-Local-Position']))
            self.response.out.write('Currently down for maintenance')
        else:
            #populate a dictionary with what we've been given in post
            #should be newline-delimited, token=value
            lines = self.request.body.split('\n')
            params = {}
            for line in lines:
                params[line.split('=')[0]] = line.split('=')[1]

            try:
                name = params['objname']
                item = tools.get_item(name, True)
                if item is None:
                    #could not find item to look up its deliverer.  return an error
                    logging.error('Error, Paid item %s not found. Requested by %s using %s.' % (name, self.request.headers['X-SecondLife-Owner-Name'], self.request.headers['X-SecondLife-Object-Name']))
                    self.error(403)
                    return
                name_version = "%s - %s" % (name, item['version'])
                rcpt = str(params['rcpt'])
                paid = int(params['paid'])
                baseprice = int(item['baseprice'])
                if paid >= baseprice:
                    pass
                else:
                    token = 'Distributor_%s' % self.request.headers['X-SecondLife-Owner-Key']
                    cacheditem = memcache.get(token)
                    if cacheditem is None:
                        dist = Distributor.gql("WHERE avkey = :1", self.request.headers['X-SecondLife-Owner-Key']).get()
                        dist_info = {"max_discount":dist.max_discount, "commission":dist.commission}
                        memcache.set(token, yaml.safe_dump(dist_info))
                    else:
                        #pull the item's details out of the yaml'd dict
                        dist_info = yaml.safe_load(cacheditem)
                    disprice = baseprice * (100-dist_info['max_discount'])/100.0
                    if paid < disprice:
                        if paid < (disprice - 50):
                            logging.error('Rejecting request: Wrong price by %s, vendor %s located in %s at %s. Item:%s Item Price:%s Price Paid:%s Max Discount:%s%%' % 
                              (self.request.headers['X-SecondLife-Owner-Name'],
                               self.request.headers['X-SecondLife-Object-Name'],
                               self.request.headers['X-SecondLife-Region'],
                               self.request.headers['X-SecondLife-Local-Position'],
                               name,
                               baseprice,
                               paid,
                               dist_info['max_discount']
                               ))
                            self.error(403)
                            self.response.out.write('Wrong amount Item:%s Item Price:%s Price Paid:%s Max Discount:%s%%' % 
                              (name,
                               baseprice,
                               paid,
                               dist_info['max_discount']
                               ))
                            return
                        else:
                            logging.warning('Under Paid Item accepting: Wrong price by %s, vendor %s located in %s at %s. Item:%s Item Price:%s Price Paid:%s Max Discount:%s' % 
                              (self.request.headers['X-SecondLife-Owner-Name'],
                               self.request.headers['X-SecondLife-Object-Name'],
                               self.request.headers['X-SecondLife-Region'],
                               self.request.headers['X-SecondLife-Local-Position'],
                               name,
                               baseprice,
                               paid,
                               ))
                            
                    
                #need to record record here
                record = Purchases(purchaser = rcpt, item = name, seller = self.request.headers['X-SecondLife-Owner-Key'], item_reciver = 'request', loc = '%s %s' % (self.request.headers['X-SecondLife-Region'], self.request.headers['X-SecondLife-Local-Position']), vender_name = self.request.headers['X-SecondLife-Object-Name'], amount_paid = paid)
                record.put()
                #have the vendor transfer the money
                self.response.out.write('pay|%s|%s|%s|%s|%s' % (moneyRcpt, paid, rcpt, name, record.key().id()))#do we need all of this?
            except KeyError:
                logging.error('Key error for paid Post vendor  %s, queue entry: %s|%s   %s' % (item['giver'], rcpt, name_version, sys.exc_info()))
                self.error(403)
예제 #13
0
 def get(self):
     if not db.WRITE_CAPABILITY.is_enabled():
         self.response.set_status(503)
         self.response.headders['Retry-After'] = 120
         logging.info("Told that the db was down for maintenance")
         self.response.out.write('Currently down for maintenance')
     else:
         t = int(time.time()) - 7200
         logging.info(
             'CRON AccountNewRecords: totaling funds for after %d' % t)
         dispersal = Dispersals()
         commissions_total = 0
         designer_total = 0
         maintainers_total = 0
         total = 0
         maintainers = AppSettings.get_or_insert(
             "maintainers",
             value="00000000-0000-0000-0000-000000000000|0").value.split(
                 "|")
         people_to_pay = []
         query = Purchases.gql("WHERE accounted = :1", "0")
         for record in query:
             logging.info('CRON: %s|%s' %
                          (record.key().id(), record.seller))
             total += record.amount_paid
             token = 'Distributor_%s' % record.seller
             cacheditem = memcache.get(token)
             if cacheditem is None:
                 dist = Distributor.gql("WHERE avkey = :1",
                                        record.seller).get()
                 dist_info = {
                     "max_discount": dist.max_discount,
                     "commission": dist.commission
                 }
                 memcache.set(token, yaml.safe_dump(dist_info))
             else:
                 #pull the item's details out of the yaml'd dict
                 dist_info = yaml.safe_load(cacheditem)
             if dist_info['commission'] > 0:
                 commission = record.paid_amount * dist_info[
                     'commission'] / 100
                 commissions_total += commission
                 stoken = '%s_seller' % (record.seller)
                 commission_total = commission + getattr(
                     dispersal, stoken, 0)
                 setattr(dispersal, stoken, commission_total)
                 people_to_pay.append(stoken)
             name = record.item
             item = tools.get_item(name, True)
             if item is None:
                 logging.error(
                     'Error, Paid item %s not found. Requested by %s using %s.'
                     %
                     (name, self.request.headers['X-SecondLife-Owner-Name'],
                      self.request.headers['X-SecondLife-Object-Name']))
             if item['designer_cut'] > 0:
                 cut = record.paid_amount * item['designer_cut'] / 100
                 designer_total += cut
                 dtoken = '%s_designer' % (item['designer'])
                 cut_total = cut + getattr(dispersal, dtoken, 0)
                 setattr(dispersal, dtoken, cut_total)
                 people_to_pay.append(dtoken)
         for maintainer, amount in zip(maintainers[::2], maintainers[1::2]):
             cut = total * int(amount) / 100
             maintainers_total += cut
             mtoken = '%s_maintainer' % (maintainer)
             setattr(dispersal, mtoken, cut)
             people_to_pay.append(mtoken)
         if query.count(1) > 0:
             if total >= (maintainers_total + designer_total +
                          commissions_total):
                 setattr(dispersal, 'commissions_total', commissions_total)
                 setattr(dispersal, 'designers_total', designer_total)
                 setattr(dispersal, 'maintainers_total', maintainers_total)
                 setattr(dispersal, 'dispersal_total',
                         (maintainers_total + designer_total +
                          commissions_total))
                 setattr(dispersal, 'total', total)
                 setattr(dispersal, 'people_to_pay',
                         "\n".join(people_to_pay))
                 dispersal.put()
                 logging.info('CRON AccountNewRecords: saved')
                 #add right url
                 taskqueue.add(url='/paiddist/disperse?id=%s' %
                               (dispersal.key().id()),
                               headers={},
                               queue_name='Disperse',
                               method='PUT')
                 for record in query:
                     record.accounted = "1"
                     record.put()
             else:
                 logging.error(
                     "CRON AccountNewRecords: total dispersal %s is greater than total paid %s"
                     % (maintainers_total + designer_total +
                        commissions_total, total))
                 redirecturl = "not needed?"
                 alarm.SendAlarm(
                     'Dispersal', t, True,
                     "total dispersal %s is greater than total paid %s" %
                     (maintainers_total + designer_total +
                      commissions_total, total), redirecturl)
                 self.error(500)
         else:
             logging.info('CRON AccountNewRecords: No records')
         logging.info('CRON AccountNewRecords: Finished')
예제 #14
0
    def post(self):
        #check linden IP  and allowed avs
        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 distributors.Contributor_authorized(
                self.request.headers['X-SecondLife-Owner-Key']):
            logging.info(
                "Illegal attempt to request redeliver from %s, box %s located in %s at %s"
                % (self.request.headers['X-SecondLife-Owner-Name'],
                   self.request.headers['X-SecondLife-Object-Name'],
                   self.request.headers['X-SecondLife-Region'],
                   self.request.headers['X-SecondLife-Local-Position']))
            self.error(403)
#don't need this for redelivery
#        elif not db.WRITE_CAPABILITY.is_enabled():
#            self.response.set_status(503)
#            self.response.headders['Retry-After'] = 120
#            logging.info("Told that the db was down for maintenance to %s, box %s located in %s at %s" % (self.request.headers['X-SecondLife-Owner-Name'], self.request.headers['X-SecondLife-Object-Name'], self.request.headers['X-SecondLife-Region'], self.request.headers['X-SecondLife-Local-Position']))
#            self.response.out.write('Currently down for maintenance')
        else:
            #populate a dictionary with what we've been given in post
            #should be newline-delimited, token=value
            lines = self.request.body.split('\n')
            params = {}
            for line in lines:
                params[line.split('=')[0]] = line.split('=')[1]

            try:
                rcpt = str(params['rcpt'])
                item_name = params['objname']
                query = Purchases.all(keys_only=True)
                query.filter('item_reciver =', rcpt)
                query.filter('item =', item_name)
                if query.count(1):
                    self.response.out.write(
                        tools.httpin_delivery(self, rcpt, item_name, ""))


#                    token = 'paid_item_%s' % item_name
#                    cacheditem = memcache.get(token)
#                    if cacheditem is None:
#                        paiditem = FreebieItem.gql("WHERE freebie_name = :1", item_name).get()
#                        if paiditem is None:
#                            #could not find item to look up its deliverer.  return an error
#                            logging.error('Error, Paid item %s not found yet was found before. Requested by %s using %s.' % (item_name, self.request.headers['X-SecondLife-Owner-Name'], self.request.headers['X-SecondLife-Object-Name']))
#                            self.error(503)
#                            return
#                        else:
#                            item = {"name":paiditem.freebie_name, "version":paiditem.freebie_version, "giver":paiditem.freebie_giver, "givers":paiditem.givers, "giver":paiditem.freebie_giver, "baseprice":paiditem.baseprice}
#                            memcache.set(token, yaml.safe_dump(item))
#                    else:
#                        #pull the item's details out of the yaml'd dict
#                        item = yaml.safe_load(cacheditem)
#                    name_version = "%s - %s" % (item_name, item['version'])
#                    if item['givers'] == []:
#                        logging.error('Error, Paid item %s does not have http urls.' % (name))
#                        self.error(503)
#                        return
#                    urls = item['givers']
#                    #need to add a way to rotate the urls
#                    url_token = 'url_%s' % item_name
#                    url_num = memcache.incr(url_token, initial_value=0)
#                    url_num = url_num % ((len(urls)/2))
#
#                    count_token = 'item_count_%s' % item_name
#                    memcache.incr(count_token, initial_value=0)
#                    #need to send itme here
#                    result = urlfetch.fetch(urls[url_num*2-1], method="POST", payload="%s|%s" % (name_version, rcpt) , headers={}, deadline = 10)
#                    if result.content == "sent":
#                        self.response.out.write('sent|%s|%s' % (rcpt, name_version))#do we need all of this?
#                    else:
#                        url_num = memcache.incr(url_token, initial_value=0)
#                        url_num = url_num % ((len(urls)/2))
#                        #need to send itme here
#                        result = urlfetch.fetch(urls[url_num*2-1], method="POST", payload="%s|%s" % (name_version, rcpt) , headers={}, deadline = 10)
#                        if result.content == "sent":
#                            self.response.out.write('sent|%s|%s' % (rcpt, name_version))#do we need all of this?
#                        else:
#                            logging.error('Error, Paid item %s did not get sent. Status %s Message from vendor: %s' % (name_version, result.status_code, result.content))
#                            self.error(503)
                else:
                    logging.error(
                        'Error, %s has no record of paid item %s yet redelvier requested it.'
                        % (rcpt, item_name))
                    self.error(404)
            except KeyError:
                logging.error(
                    'Key error for paid redeliver vendor %s, queue entry: %s|%s   %s'
                    % (self.request.headers['X-SecondLife-Object-Key'], rcpt,
                       item_name, sys.exc_info()))
                self.error(403)
예제 #15
0
    def post(self):
        #check linden IP  and allowed avs
        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 distributors.Distributor_authorized(
                self.request.headers['X-SecondLife-Owner-Key']):
            logging.warning(
                "Illegal attempt to request an item from %s, box %s located in %s at %s"
                % (self.request.headers['X-SecondLife-Owner-Name'],
                   self.request.headers['X-SecondLife-Object-Name'],
                   self.request.headers['X-SecondLife-Region'],
                   self.request.headers['X-SecondLife-Local-Position']))
            self.error(403)
        elif not db.WRITE_CAPABILITY.is_enabled():
            self.response.set_status(503)
            self.response.headders['Retry-After'] = 120
            logging.info(
                "Told that the db was down for maintenance to %s, box %s located in %s at %s"
                % (self.request.headers['X-SecondLife-Owner-Name'],
                   self.request.headers['X-SecondLife-Object-Name'],
                   self.request.headers['X-SecondLife-Region'],
                   self.request.headers['X-SecondLife-Local-Position']))
            self.response.out.write('Currently down for maintenance')
        else:
            #populate a dictionary with what we've been given in post
            #should be newline-delimited, token=value
            lines = self.request.body.split('\n')
            params = {}
            for line in lines:
                params[line.split('=')[0]] = line.split('=')[1]

            try:
                name = params['objname']
                item = tools.get_item(name, True)
                if item is None:
                    #could not find item to look up its deliverer.  return an error
                    logging.error(
                        'Error, Paid item %s not found. Requested by %s using %s.'
                        %
                        (name, self.request.headers['X-SecondLife-Owner-Name'],
                         self.request.headers['X-SecondLife-Object-Name']))
                    self.error(403)
                    return
                name_version = "%s - %s" % (name, item['version'])
                rcpt = str(params['rcpt'])
                paid = int(params['paid'])
                baseprice = int(item['baseprice'])
                if paid >= baseprice:
                    pass
                else:
                    token = 'Distributor_%s' % self.request.headers[
                        'X-SecondLife-Owner-Key']
                    cacheditem = memcache.get(token)
                    if cacheditem is None:
                        dist = Distributor.gql(
                            "WHERE avkey = :1", self.request.
                            headers['X-SecondLife-Owner-Key']).get()
                        dist_info = {
                            "max_discount": dist.max_discount,
                            "commission": dist.commission
                        }
                        memcache.set(token, yaml.safe_dump(dist_info))
                    else:
                        #pull the item's details out of the yaml'd dict
                        dist_info = yaml.safe_load(cacheditem)
                    disprice = baseprice * (100 -
                                            dist_info['max_discount']) / 100.0
                    if paid < disprice:
                        if paid < (disprice - 50):
                            logging.error(
                                'Rejecting request: Wrong price by %s, vendor %s located in %s at %s. Item:%s Item Price:%s Price Paid:%s Max Discount:%s%%'
                                %
                                (self.request.
                                 headers['X-SecondLife-Owner-Name'], self.
                                 request.headers['X-SecondLife-Object-Name'],
                                 self.request.headers['X-SecondLife-Region'],
                                 self.request.
                                 headers['X-SecondLife-Local-Position'], name,
                                 baseprice, paid, dist_info['max_discount']))
                            self.error(403)
                            self.response.out.write(
                                'Wrong amount Item:%s Item Price:%s Price Paid:%s Max Discount:%s%%'
                                % (name, baseprice, paid,
                                   dist_info['max_discount']))
                            return
                        else:
                            logging.warning(
                                'Under Paid Item accepting: Wrong price by %s, vendor %s located in %s at %s. Item:%s Item Price:%s Price Paid:%s Max Discount:%s'
                                % (
                                    self.request.
                                    headers['X-SecondLife-Owner-Name'],
                                    self.request.
                                    headers['X-SecondLife-Object-Name'],
                                    self.request.
                                    headers['X-SecondLife-Region'],
                                    self.request.
                                    headers['X-SecondLife-Local-Position'],
                                    name,
                                    baseprice,
                                    paid,
                                ))

                #need to record record here
                record = Purchases(
                    purchaser=rcpt,
                    item=name,
                    seller=self.request.headers['X-SecondLife-Owner-Key'],
                    item_reciver='request',
                    loc='%s %s' %
                    (self.request.headers['X-SecondLife-Region'],
                     self.request.headers['X-SecondLife-Local-Position']),
                    vender_name=self.request.
                    headers['X-SecondLife-Object-Name'],
                    amount_paid=paid)
                record.put()
                #have the vendor transfer the money
                self.response.out.write(
                    'pay|%s|%s|%s|%s|%s' %
                    (moneyRcpt, paid, rcpt, name,
                     record.key().id()))  #do we need all of this?
            except KeyError:
                logging.error(
                    'Key error for paid Post vendor  %s, queue entry: %s|%s   %s'
                    % (item['giver'], rcpt, name_version, sys.exc_info()))
                self.error(403)
예제 #16
0
    def post(self):
        #check linden IP  and allowed avs
        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 distributors.Distributor_authorized(self.request.headers['X-SecondLife-Owner-Key']):
#            logging.info("Illegal attempt to request an item from %s, box %s located in %s at %s" % (self.request.headers['X-SecondLife-Owner-Name'], self.request.headers['X-SecondLife-Object-Name'], self.request.headers['X-SecondLife-Region'], self.request.headers['X-SecondLife-Local-Position']))
#            self.error(403)
        elif not db.WRITE_CAPABILITY.is_enabled():
            self.response.set_status(503)
            self.response.headders['Retry-After'] = 120
            logging.info(
                "Told that the db was down for maintenance to %s, box %s located in %s at %s"
                % (self.request.headers['X-SecondLife-Owner-Name'],
                   self.request.headers['X-SecondLife-Object-Name'],
                   self.request.headers['X-SecondLife-Region'],
                   self.request.headers['X-SecondLife-Local-Position']))
            self.response.out.write('Currently down for maintenance')
        else:
            #populate a dictionary with what we've been given in post
            #should be newline-delimited, token=value
            lines = self.request.body.split('\n')
            params = {}
            for line in lines:
                params[line.split('=')[0]] = line.split('=')[1]

            try:
                name = params['objname']
                item = tools.get_item(name, True)
                if item is None:
                    #could not find item to look up its deliverer.  return an error
                    logging.error(
                        'Error, Paid item %s not found. Requested by %s using %s.'
                        %
                        (name, self.request.headers['X-SecondLife-Owner-Name'],
                         self.request.headers['X-SecondLife-Object-Name']))
                    self.error(403)
                    return
                name_version = "%s - %s" % (name, item['version'])
                rcpt = self.request.headers['X-SecondLife-Owner-Key']
                paid = int(params['paid'])
                baseprice = int(item['baseprice'])
                if paid >= baseprice:
                    pass
                else:

                    logging.error(
                        'Rejecting request: Wrong price by %s, gift vendor %s located in %s at %s. Item:%s Item Price:%s Price Paid:%s'
                        % (self.request.headers['X-SecondLife-Owner-Name'],
                           self.request.headers['X-SecondLife-Object-Name'],
                           self.request.headers['X-SecondLife-Region'],
                           self.request.headers['X-SecondLife-Local-Position'],
                           name, baseprice, paid))
                    self.error(403)
                    return
                #need to record record here
                record = Purchases(
                    purchaser=rcpt,
                    item=name,
                    seller=self.request.headers['X-SecondLife-Owner-Key'],
                    item_reciver='gift request',
                    loc='%s %s' %
                    (self.request.headers['X-SecondLife-Region'],
                     self.request.headers['X-SecondLife-Local-Position']),
                    vender_name=self.request.
                    headers['X-SecondLife-Object-Name'],
                    amount_paid=paid)
                record.put()
                #have the vendor transfer the money
                self.response.out.write(
                    'pay|%s|%s|%s|%s|%s' %
                    (moneyRcpt, paid, rcpt, name,
                     record.key().id()))  #do we need all of this?
            except KeyError:
                logging.error(
                    'Key error for paid Post gift vendor  %s, queue entry: %s|%s   %s'
                    % (item['giver'], rcpt, name_version, sys.exc_info()))
                self.error(403)