예제 #1
0
 def get(self):
     Gadget = self.request.get('Gadget')
     logging.debug("Gadget: %s" % Gadget)
     memtoken = "VendorPage"
     message = memcache.get(memtoken)
     if message is None:
         message = ''
         query = VendorInfo.gql("WHERE public=1 ORDER BY agerating ASC, parcel ASC, lastupdate ASC")
         if query.count()==0:
             message = '<b>Currently no vendors are listed!</b>'
         else:
             message = '<table class="sortable" border=\"1\">'
             message += '<tr><th>Row</th><th>Parcel</th><th>AgeRating</th><th>SLURL</th></tr><br />\n'
             content = []
             locList = []
             for record in query:
                 locStamp = '%s|%s' % (record.parcel, record.sim)
                 if locStamp not in locList:
                     locList += [locStamp]
                     content += ['<td>%s</td><td>%s</td><td><a target="_blank" href="%s">%s</a></td>\n' % (record.parcel, record.agerating, record.slurl, record.slurl)]
             for i in range(0,len(content)):
                 message += '<tr><td>%d</td>%s' % (i+1, content[i])
             message += "</table>"
         memcache.set(memtoken, message)
     if Gadget=="1":
         logging.debug("Output to Gadget")
         self.response.out.write((head_gadget % 'OpenCollar Vendor Locations') + message + end)
     else:
         logging.debug("Output to page")
         self.response.out.write((head % 'OpenCollar Vendor Locations') + message + end)
예제 #2
0
def UpdateVendorInfo (vendorkey, vowner, public, sim_id, body):
    logging.info('vendorkey: %s, vowner: %s, public: %s, sim: %s, body: %s' % (vendorkey, vowner, public, sim_id, body))
    db_key = "key_%s" % vendorkey
    t=int(time.time())
    record = VendorInfo.get_by_key_name(db_key)
    sim_id = sim_id[0:string.find(sim_id,'(')]

    if body != "":
        lines = body.split('\n')
        slurl = lines[0]
        parcelName = lines[1]
        parcelRating = lines [2]
    else:
        slurl = ''
        parcelName = ''
        parcelRating = ''

    VendorPageToken = "VendorPage"

    if record is None:
        if public=='1':
            VendorInfo(key_name=db_key, vkey = vendorkey, owner = vowner, slurl = slurl, parcel = parcelName, agerating = parcelRating, lastupdate = t, public = 1, sim = sim_id).put()
            logging.info("Adding vendor %s, now at SLURL %s in sim %s" % (vendorkey, slurl, sim_id))
            memcache.delete(VendorPageToken)


    else:
        if public == '0':
            logging.info("Removing vendor %s as it is set to NON public now" % vendorkey)
            record.delete()
            memcache.delete(VendorPageToken)
        elif record.slurl != slurl:
            record.owner = vowner
            record.slurl = slurl
            record.parcel = parcelName
            record.agerating = parcelRating
            record.lastupdate = t
            record.public = 1
            record.sim = sim_id
            logging.info("Updating info for vendor %s, now at SLURL %s in sim %s" % (vendorkey, slurl, sim_id))
            record.put()
            memcache.delete(VendorPageToken)
        else:
            record.lastupdate = t
            record.public = 1
            logging.info("Updating  timestamp for vendor %s (%d)" % (vendorkey, t))
            record.put()
예제 #3
0
파일: cron.py 프로젝트: lkalif/collardata
 def get(self):
     t=int(time.time()) - VendorRemoveTimeout;
     logging.info('CRON CleanVendors: Removing vendors older than %d' % t)
     query = VendorInfo.gql("WHERE lastupdate < :1",  t)
     for record in query:
         logging.info('CRON: Vendor info for %s at %s outdated, removing it' % (record.vkey, record.slurl))
         record.delete()
     memcache.delete(VendorPageToken)
     logging.info('CRON CleanVendors: Finished')
예제 #4
0
def UpdateVendorInfo(vendorkey, vowner, public, sim_id, body):
    logging.info("vendorkey: %s, vowner: %s, public: %s, sim: %s, body: %s" % (vendorkey, vowner, public, sim_id, body))
    db_key = "key_%s" % vendorkey
    t = int(time.time())
    record = VendorInfo.get_by_key_name(db_key)
    sim_id = sim_id[0 : string.find(sim_id, "(")]

    if body != "":
        lines = body.split("\n")
        slurl = lines[0]
        parcelName = lines[1]
        parcelRating = lines[2]
    else:
        slurl = ""
        parcelName = ""
        parcelRating = ""

    VendorPageToken = "VendorPage"

    if record is None:
        if public == "1":
            VendorInfo(
                key_name=db_key,
                vkey=vendorkey,
                owner=vowner,
                slurl=slurl,
                parcel=parcelName,
                agerating=parcelRating,
                lastupdate=t,
                public=1,
                sim=sim_id,
            ).put()
            logging.info("Adding vendor %s, now at SLURL %s in sim %s" % (vendorkey, slurl, sim_id))
            memcache.delete(VendorPageToken)

    else:
        if public == "0":
            logging.info("Removing vendor %s as it is set to NON public now" % vendorkey)
            record.delete()
            memcache.delete(VendorPageToken)
        elif record.slurl != slurl:
            record.owner = vowner
            record.slurl = slurl
            record.parcel = parcelName
            record.agerating = parcelRating
            record.lastupdate = t
            record.public = 1
            record.sim = sim_id
            logging.info("Updating info for vendor %s, now at SLURL %s in sim %s" % (vendorkey, slurl, sim_id))
            record.put()
            memcache.delete(VendorPageToken)
        else:
            record.lastupdate = t
            record.public = 1
            logging.info("Updating  timestamp for vendor %s (%d)" % (vendorkey, t))
            record.put()
예제 #5
0
 def get(self):
     t = int(time.time()) - VendorRemoveTimeout
     logging.info('CRON CleanVendors: Removing vendors older than %d' % t)
     query = VendorInfo.gql("WHERE lastupdate < :1", t)
     for record in query:
         logging.info(
             'CRON: Vendor info for %s at %s outdated, removing it' %
             (record.vkey, record.slurl))
         record.delete()
     memcache.delete(VendorPageToken)
     logging.info('CRON CleanVendors: Finished')