如何在Google App Engine(GAE)上运行的Web2py上创建新的auth_user和auth_group? [英] How can I create new auth_user and auth_group on Web2py running on Google App Engine (GAE)?

查看:200
本文介绍了如何在Google App Engine(GAE)上运行的Web2py上创建新的auth_user和auth_group?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Web2py在本地计算机上创建了一个应用程序,并通过带有SQLite的WSGI运行。我可以成功地将我的应用程序部署到Google App Engine,并使用我自己的域名进行所需的所有url重写。



现在我需要一种方法来创建特定的管理用户负责更新一些表格。

具体问题:


  1. 有没有我可以在GAE上运行应用程序时使用Web2py管理界面吗?

  2. 即使我不想创建新闻应用程序或编辑文件,是否可以使用Web2py管理界面进行管理在Google App引擎上运行的应用程序的数据库?

  3. 如果不是,在GAE上使用W​​eb2py时如何完成这种用户管理?


解决方案

我以前从未使用过GAE,但我通常在db.py中创建一个初始管理用户: / b>

  def check_initialize():
如果不是db()。select(db.auth_user.ALL).first() :
db.auth_user.insert(
username ='administrator',
password = db.auth_user.password.validate('admin1234')[0],
email =' null@null.com',
first_name ='系统',
last_name ='Administrator',
is_admin = True,


#进行初始化检查
cache.ram('db_initialized', lambda:check_initialize(),time_expire = None)

请注意,is_admin是我添加到的字段auth_user表,但我可以轻松地添加一个名为administrators的新auth_group记录,然后使用auth.add_membership(1,1)将新用户添加到administrators组中。



对于管理功能,如果您无法使web2py admin正常工作(如果您将web2py设置为通过HTTPS运行,应该可以),那么您始终可以使用某些东西创建自己的编辑器像这样:
$ b

  def users():
form = SQLFORM.grid(db.auth_user)
return dict(form = form)

这将创建一个列出所有用户的网格控件,并允许您添加和删​​除用户。你可以为db.auth_group和db.auth_membership做同样的事情。你可能需要稍微调整一下。或者,您始终可以使用以下内容:即时管理 Badmin


I've created an app on my local computer with Web2py and it is running via WSGI with SQLite. I can successfully deploy my app to Google App Engine, using my own domain and doing all url rewrites I need.

Now I need a way to create specific administrative users that will be responsible for update some tables.

Specific questions:

  1. Is there a way I can use Web2py admin interface when my appliation is running on GAE ?
  2. Even if I do not want create news applications nor edit files, is it possible to use Web2py admin interface just to manage the database of an application running on Google App engine?
  3. If not, how this kind of user management is done when using Web2py on GAE?

解决方案

I've never used GAE before, but I usually do something like this in my db.py to create an initial administrative user:

def check_initialize():
    if not db().select(db.auth_user.ALL).first():        
        db.auth_user.insert(
            username = 'administrator',
            password = db.auth_user.password.validate('admin1234')[0],
            email = 'null@null.com',
            first_name = 'System',
            last_name = 'Administrator',
            is_admin = True,
        )

# do initialization check
cache.ram('db_initialized', lambda: check_initialize(), time_expire=None)

Note that "is_admin" is a field I added to the auth_user table, but I could have just as easily added a new auth_group record called "administrators", and then added the new user to the "administrators" group using "auth.add_membership(1, 1)".

For administrative functions, if you can't get the web2py admin working (which should be possible if you set up web2py to run over HTTPS), then you can always create your own editor using something like this:

def users():
    form = SQLFORM.grid(db.auth_user)
    return dict(form=form)

That will create a grid control listing all users, and allowing you to add and remove users. You could do the same thing for db.auth_group and db.auth_membership. You may need to tweak it a bit though. Alternatively, you could always use something like this: Instant Admin or Badmin

这篇关于如何在Google App Engine(GAE)上运行的Web2py上创建新的auth_user和auth_group?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆