Exemplo n.º 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)