Esempio n. 1
0
    def log_entry(self):
        google_user = users.get_current_user()
        user = self.get_current_user()
        
        # log request in database
        log_entry = SiteLog()
        log_entry.language = self.get_language()
        log_entry.page = self.request.path
        log_entry.ip = self.request.remote_addr
        log_entry.referer = self.request.referer

        if "X-AppEngine-Country" in self.request.headers:
            log_entry.gae_country = self.request.headers["X-AppEngine-Country"]

        if "X-AppEngine-Region" in self.request.headers:
            log_entry.gae_region = self.request.headers["X-AppEngine-Region"]

        if "X-AppEngine-City" in self.request.headers:
            log_entry.gae_city = self.request.headers["X-AppEngine-City"]

        if "X-AppEngine-CityLatLong" in self.request.headers:
            log_entry.gae_city_lat_long = self.request.headers["X-AppEngine-CityLatLong"]

        if user:
            log_entry.user_email = user.get_email()
            log_entry.user = user.key

        if google_user:
            log_entry.admin_email = google_user.email()
            
        if self.session.has_key('prospect_id'):
            prospect_id = self.session['prospect_id']
            if prospect_id:
                prospect = db.get_prospect_from_prospect_id(prospect_id)
                
                if prospect_id:
                    log_entry.prospect_id = prospect_id
                
                if prospect:
                    log_entry.prospect = prospect.key
           
           
        log_entry.put_async()