本文整理汇总了Python中models.Profile.gql方法的典型用法代码示例。如果您正苦于以下问题:Python Profile.gql方法的具体用法?Python Profile.gql怎么用?Python Profile.gql使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Profile
的用法示例。
在下文中一共展示了Profile.gql方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: edit
# 需要导入模块: from models import Profile [as 别名]
# 或者: from models.Profile import gql [as 别名]
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: index
# 需要导入模块: from models import Profile [as 别名]
# 或者: from models.Profile import gql [as 别名]
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: unicode
# 需要导入模块: from models import Profile [as 别名]
# 或者: from models.Profile import gql [as 别名]
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):