コード例 #1
0
ファイル: views.py プロジェクト: junwchina/gae-todo
def list_todo(request):
    user = request.user
    if user.is_authenticated():
      todos = get_object_list(Todo, "user =", user.key()).fetch(999)     
      return render_to_response(request, 'todo_list.html', {'todos':paginate(request, todos)}) 
    else:
      return HttpResponseRedirect('http://localhost:8000/_ah/login?continue=http://notalma.appspot.com')
コード例 #2
0
def show_gallery(request, key):
    g = get_object(Gallery, key)

    images = None
    if g:
      images = get_object_list(Photo, "gallery =", g.key()).fetch(50)
    
    return render_to_response(request, 'gallery_detail.html', {'g': g, 'g_images': images})
コード例 #3
0
 def render(self, context):
     #items = self.model._default_manager.all().order('-created').filter("published = ", True)#[:self.num]
     #items = get_object_list(self.model, "published = ", True).order('-created').fetch(self.num)
     items = get_object_list(self.model).fetch()
     n = 1
     newlist[]
     for i in len(items):
       newlist[n].append(i)
       if n % 3:
         n += 1
     context[self.varname] = newlist
     return ''
コード例 #4
0
def menu(request):

    menu_items = get_object_list(Category).order('order').fetch(100)
    menu = []

    for el in (cc for cc in menu_items if cc.code != 'news'):
        menu.append( (el,el.pages_set.order('order').fetch(10),) )

    return {
            'menu':menu
    }
    
コード例 #5
0
ファイル: backends.py プロジェクト: hnfong/bugivore
   def map_to_existing_user_by_email(self, auth_info):
       """Map open ID to existing user based on email.
       
       The open Id provider needs to be in the TRUSTED_PROVIDERS
       list to be able to do this mapping.
       """
       if not auth_info or auth_info.__class__ != RpxAuthInfo:
           raise ValueError
       
       user = None
       
       if auth_info.get_provider() in TRUSTED_PROVIDERS:
           
           user_candidates = dbutils.get_object_list(User, 'email = ', auth_info.get_email())
 
           if user_candidates.count() == 1:
               users = user_candidates.fetch(1)
               user = users[0]
               rpxdata = RpxData(key_name=self.create_rpx_key(auth_info.get_rpx_id()), user=user)
               self.logger.info("RpxBackend: New RPX id for existing user: " + user.username)
       
       return user