示例#1
0
 def process_response(self, request, response):
     if '/static/' in request.path:
         return response
     
     if 'html' in response.get('Content-Type', '') or 'javascript' in response.get('Content-Type', ''):
         return response
     
     log = "-------------------------------------\n%(timestamp)s\n%(headers)s\n%(request)s\nHANDLER: %(method)s %(url)s\nRESPONSE\n%(response)s\n-------------------------------------\n" 
     msg = ""
     try:
         if request.GET:
             msg += "REQUEST GET: %s" % toDict(request.GET)
         if request.POST:
             msg += "REQUEST POST: %s" % toDict(request.POST)
         if request.FILES:
             msg += 'FILES: %s' % ','.join([f.name for f in request.FILES.itervalues()])
     except Exception, e:
         msg += "Error retreiving request data: %s" % e
示例#2
0
 def dict(self):
     ret = utils.toDict(self)
     del ret['geolocation']
     del ret['street']
     del ret['city']
     del ret['zip']
     del ret['country']
     del ret['cross_street']
     del ret['state']
     ret['address'] = self.address
     return ret
示例#3
0
 def save(self, *args, **kwargs):
     if not self.id:
         if hasattr(consts, 'BADGE_AWARDED_TEMPLATE'):
             message_template = consts.BADGE_AWARDED_TEMPLATE
         else:
             message_template =  "You've earned the %(name)s badge!"
         badge = self.badge
         message_text = message_template % {'name': badge.name}
         message_data = utils.toDict(self.badge)
         message_data['images'] = badge.images
         message_data['message'] = message_text
         message_data['type'] = 'badge_event'
         message_sent.send(sender=self.winner.user, message=message_data)
         
     super(BadgeToUser, self).save(*args, **kwargs)