usermixin.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:websauna 作者: websauna 项目源码 文件源码
def init_empty_site(self, dbsession:Session, user:UserMixin):
        """When the first user signs up build the admin groups and make the user member of it.

        Make the first member of the site to be admin and superuser.
        """

        # Try to reflect related group class based on User model
        i = inspection.inspect(user.__class__)
        Group = i.relationships["groups"].mapper.entity

        # Do we already have any groups... if we do we probably don'¨t want to init again
        if dbsession.query(Group).count() > 0:
            return

        g = Group(name=Group.DEFAULT_ADMIN_GROUP_NAME)
        dbsession.add(g)

        g.users.append(user)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号