示例#1
0
def edit(request):
  user=users.GetCurrentUser()
  if user is None:
    return http.HttpResponseForbidden('You must be signed in to add or edit a greeting')
  profile=Profile.gql("where user=:1",user).get()
  form = ProfileForm(data=request.POST or None, instance=profile)

  if not request.POST:
    return views.respond(request, user, 'profiles/form', {'form': form, 'current_profile': profile})

  errors = form.errors
  if not errors:
    try:
      profile = form.save(commit=False)
    except ValueError, err:
      errors['__all__'] = unicode(err)
示例#2
0
def index(request):
  """Request / -- show all posts."""
  user=users.GetCurrentUser()
  profiles = Profile.gql("ORDER BY postCount DESC LIMIT 20")
  return views.respond(request, user, 'profiles/index',
                       {'profiles': profiles})
示例#3
0
文件: posts.py 项目: oloed/talk.org
  if not request.POST:
    return views.respond(request, user, 'posts/create', 
                         {'form': form})
  
    
  errors = form.errors
  if not errors:
    try:
      post = form.save(commit=False)
    except ValueError, err:
      errors['__all__'] = unicode(err)
  if errors:
    return views.respond(request, user, 'posts/create', 
                         {'form': form})
  
  profile=Profile.gql("where user=:1",user).get()
  
  if profile is None:
    profile=Profile.For(user)
  post.owner = user
  post.author = profile
  post.put()
  profile.increase_count()
  
  memcache.delete("latest_posts")
  profile.clear_post_cache()
  
  logging.info('Saved the post, %s' % post)
  return http.HttpResponseRedirect('/')

def show(request,key):