Ejemplo n.º 1
0
 def get(self):
     pageIndex = int(self.request.get('p', '0'))
     appUser = models.get_or_create_appUser()
     if appUser:
       pages, next = models.get_pages_for_user(appUser, pageIndex, 20)
       if next:
        nexturi = 'http://' + os.environ['HTTP_HOST'] + '/a/get/?p=%d' % (pageIndex + 1)
       else:
        nexturi = None
       if pageIndex > 1:
        prevuri = 'http://' + os.environ['HTTP_HOST'] + '/a/get/?p=%d' % (pageIndex - 1)
       elif pageIndex == 1:
        prevuri = 'http://' + os.environ['HTTP_HOST'] + '/a/get/'
       else:
        prevuri = None
       
       params = {}
       jsonPages=[] 
       for page in pages:
           json = {}
           json['edit'] = 'http://' + os.environ['HTTP_HOST'] + '/a/edit/' + str(page.key())
           json['name'] = page.name
           json['id'] = str(page.key().id())
           json['updated'] = page.updated 
           jsonPages.append(json)
       if nexturi:
           params['nextIndex'] = str((pageIndex + 1))
       if prevuri:
           params['prevIndex'] = str((pageIndex - 1))
       params['pages'] = jsonPages
       self.response.out.write(respond_to_request(self.request, users.get_current_user(), 'open_page.html', params))
     else:
      self.error(403)
Ejemplo n.º 2
0
Archivo: fb.py Proyecto: vkreal/pagefin
 def get(self):
     pageIndex = int(self.request.get('p', '0'))
     uid = cgi.escape(self.request.get('uid'))
     appUser = models.AppUser.get_by_key_name(str(uid))
     apKeys = _getFBKeys(self.request)
     fb = facebook.Facebook(apKeys['FbApiKey'], apKeys['FbSecret'])
     if appUser and fb:
       pages, next = models.get_pages_for_user(appUser, pageIndex, 16)
       if next:
        nexturi = True
       else:
        nexturi = False
       if pageIndex > 1:
        prevuri = True
       elif pageIndex == 1:
        prevuri = True
       else:
        prevuri = False
       
       params = {}
       params['pages'] = pages;
       if nexturi:
           params['nextIndex'] = str((pageIndex + 1))
       if prevuri:
           params['prevIndex'] = str((pageIndex - 1))
       params['pageIndex'] = pageIndex
       self.response.out.write(fb_respond_to_request(self.request, 'fb_open_page.html', params))
     else:
      self.error(403)