python - 在 appengine 上使用 webapp2 创建用户配置文件

标签 python google-app-engine webapp2

在 webapp2/appengine 中创建用户的一个非常简单的用例如下:

from google.appengine.api import users


class MainPage(webapp.RequestHandler):
    def get(self):
        user = users.get_current_user()

        if user:
            self.response.headers['Content-Type'] = 'text/plain'
            self.response.out.write('Hello, ' + user.nickname())
        else:
            self.redirect(users.create_login_url(self.request.uri))

但如果我们想要一个用户配置文件,其中包含更多特定于应用程序的任务。假设一个用户可以有地址和电话号码,他的一些健康信息如血糖等。我们如何从 API 扩展用户以创建用户配置文件。

最佳答案

使用链接到用户的属性定义模型:db.ReferenceProperty(users.User)

关于python - 在 appengine 上使用 webapp2 创建用户配置文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11063158/

相关文章:

python - SQLAlchemy - 使用与数据库和 session 的连接(不明确的行为和文档中的部分)

python - 将 GAE 模型转换为 JSON

python - 在 Google AppEngine 开发上打开 APNS 套接字时出现权限被拒绝错误

python - 加快 pandas 滚动窗口的速度

python - 是什么导致 "AttributeError: ' numpy.ndarray' 对象没有属性 'diff' “

python - 如何制作一个抽象的 Haystack SearchIndex 类

java - 如何从应用程序引擎上的 memcached 获取字符串 - java

python - 为你的 Python 博客生成 XML/Feed

python - Google App Engine 中的 RedirectRoute 和 url 参数

javascript - webapp2 cookie 检索不完整