当前位置: 首页>>代码示例>>Python>>正文


Python Group.create方法代码示例

本文整理汇总了Python中models.Group.create方法的典型用法代码示例。如果您正苦于以下问题:Python Group.create方法的具体用法?Python Group.create怎么用?Python Group.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Group的用法示例。


在下文中一共展示了Group.create方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: populate_with_defaults

# 需要导入模块: from models import Group [as 别名]
# 或者: from models.Group import create [as 别名]
def populate_with_defaults():
    '''Create user admin and grant him all permission

    If the admin user already exists the function will simply return
    '''
    logging.getLogger(__name__).debug("Populating with default users")
    if not User.select().where(User.name == 'admin').exists():
        admin = User.create(name='admin', password='admin')
        admins = Group.create(name='admins')
        starCap = Capability.create(domain='.+',
                                    action=(Action.CREATE |
                                            Action.READ |
                                            Action.UPDATE |
                                            Action.DELETE))
        admins.capabilities.add(starCap)
        admin.groups.add(admins)
        admin.save()
    if not User.select().where(User.name == 'anonymous').exists():
        anon = User.create(name='anonymous', password='')
        anons = Group.create(name='anonymous')
        readCap = Capability.create(domain=Capability.simToReg('/volumes/*'),
                                    action=Action.READ)
        anons.capabilities.add(readCap)
        anon.groups.add(anons)
        anon.save()
开发者ID:insomnia-lab,项目名称:libreant,代码行数:27,代码来源:__init__.py

示例2: init

# 需要导入模块: from models import Group [as 别名]
# 或者: from models.Group import create [as 别名]
def init():
    ''' Initialize the database '''
    print('Initializing')
    barrel.db.init(app)

    Role.create(name='admin')
    Role.create(name='mod')
    Role.create(name='user')

    Group.create(
        abbr=u'ACME',
        name=u'Administration, Control and Management Environment')

    add_user('admin', 'nidma', 'admin', group=Group.get_admin_group())

    return 'Database initialized successfully'
开发者ID:otech-nl,项目名称:barrel,代码行数:18,代码来源:do.py

示例3: get_group

# 需要导入模块: from models import Group [as 别名]
# 或者: from models.Group import create [as 别名]
 def get_group(self, title):
     db.connect()
     try:
         g = Group.get(Group.title == title)
     except Group.DoesNotExist:
         g = Group.create(title = title)
     db.close()
     return g
开发者ID:matsufan,项目名称:bottle-fever,代码行数:10,代码来源:users.py

示例4: get

# 需要导入模块: from models import Group [as 别名]
# 或者: from models.Group import create [as 别名]
    def get(self):

        # Check if the list name is provided
        user_key = self.request.get('user_key')
        name = self.request.get('name')

        try:
            # Add the new list to the database
            new_content = Group.create(user_key, name)

            # Respond with the list key
            self.response.set_status(201)
            self.response.write(new_content)
        except Exception as e:
            # Respond with the error
            self.response.set_status(406)
            self.response.write(str(e))
开发者ID:RyanMitch16,项目名称:code-u-final,代码行数:19,代码来源:main.py

示例5: register

# 需要导入模块: from models import Group [as 别名]
# 或者: from models.Group import create [as 别名]
def register():
    group_name = request.form['group'].strip()
    player_name = request.form['player'].strip()

    try:
        # Perform case-insensitive search.
        group = Group.get(fn.Lower(Group.name) == group_name.lower())
    except:
        group = Group.create(name=group_name)

    try:
        # Perform case-insensitive search.
        player = Player.get(fn.lower(Player.name) == player_name.lower(), group=group)
    except Player.DoesNotExist:
        player = Player.create(
            group=group, name=player_name, order=group.players.count())

    return str(player.id)
开发者ID:ChickTech,项目名称:puzzle-hunt,代码行数:20,代码来源:flask_app.py

示例6: get_group

# 需要导入模块: from models import Group [as 别名]
# 或者: from models.Group import create [as 别名]
 def get_group(self, title):
     try:
         g = Group.get(Group.title == title)
     except Group.DoesNotExist:
         g = Group.create(title = title)
     return g
开发者ID:SimonCoopey,项目名称:bottle-fever,代码行数:8,代码来源:users.py


注:本文中的models.Group.create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。