Exemplo n.º 1
0
    def configure_user_models(self):
        """Plug in user models.

        This initialization step connects chosen user model to SQLAlchemy model Base. Also set up :py:class:`websauna.system.user.usermixin.SiteCreator` logic - what happens when the first user logs in.
        """

        from websauna.system.model.meta import Base

        from websauna.system.user import models
        from websauna.system.user.interfaces import IGroupModel, IUserModel, ISiteCreator
        from websauna.system.user.usermixin import SiteCreator
        from websauna.system.user.userregistry import DefaultEmailBasedUserRegistry
        from websauna.system.user.interfaces import IActivationModel, IUserRegistry
        from websauna.system.model.utils import attach_model_to_base

        attach_model_to_base(models.User, Base)
        attach_model_to_base(models.Group, Base)
        attach_model_to_base(models.Activation, Base)
        attach_model_to_base(models.UserGroup, Base)

        # Mark active user and group class
        registry = self.config.registry
        registry.registerUtility(models.User, IUserModel)
        registry.registerUtility(models.Group, IGroupModel)
        registry.registerUtility(models.Activation, IActivationModel)

        site_creator = SiteCreator()
        registry.registerUtility(site_creator, ISiteCreator)

        # Which user registry we are using
        registry.registerAdapter(factory=DefaultEmailBasedUserRegistry,
                                 required=(IRequest, ),
                                 provided=IUserRegistry)
Exemplo n.º 2
0
    def configure_user_models(self):
        """Plug in user models.

        This initialization step connects chosen user model to SQLAlchemy model Base. Also set up :py:class:`websauna.system.user.usermixin.SiteCreator` logic - what happens when the first user logs in.
        """

        from websauna.system.model.meta import Base

        from websauna.system.user import models
        from websauna.system.user.interfaces import IGroupModel, IUserModel, ISiteCreator
        from websauna.system.user.usermixin import SiteCreator
        from websauna.system.user.userregistry import DefaultEmailBasedUserRegistry
        from websauna.system.user.interfaces import IActivationModel, IUserRegistry

        attach_model_to_base(models.User, Base)
        attach_model_to_base(models.Group, Base)
        attach_model_to_base(models.Activation, Base)
        attach_model_to_base(models.UserGroup, Base)

        # Mark active user and group class
        registry = self.config.registry
        registry.registerUtility(models.User, IUserModel)
        registry.registerUtility(models.Group, IGroupModel)
        registry.registerUtility(models.Activation, IActivationModel)

        site_creator = SiteCreator()
        registry.registerUtility(site_creator, ISiteCreator)

        # Which user registry we are using
        registry.registerAdapter(factory=DefaultEmailBasedUserRegistry, required=(IRequest,), provided=IUserRegistry)
Exemplo n.º 3
0
    def configure_user_models(self):
        """Plug in user models.

        Connect chosen user model to SQLAlchemy model Base. Also set up :py:class:`websauna.system.user.usermixin.SiteCreator` logic - what happens when the first user logs in.
        """
        from websauna.system.user import models
        from websauna.system.model.meta import Base
        from websauna.system.user.interfaces import IGroupClass, IUserClass, ISiteCreator
        from websauna.system.user.usermixin import SiteCreator
        from horus.interfaces import IActivationClass

        attach_model_to_base(models.User, Base)
        attach_model_to_base(models.Group, Base)
        attach_model_to_base(models.Activation, Base)
        attach_model_to_base(models.UserGroup, Base)

        # Mark active user and group class
        registry = self.config.registry
        registry.registerUtility(models.User, IUserClass)
        registry.registerUtility(models.Group, IGroupClass)

        site_creator = SiteCreator()
        registry.registerUtility(site_creator, ISiteCreator)

        # TODO: Get rid of Horus
        registry.registerUtility(models.Activation, IActivationClass)
Exemplo n.º 4
0
    def configure_user_models(self):
        """Plug in user models.

        Connect chosen user model to SQLAlchemy model Base. Also set up :py:class:`websauna.system.user.usermixin.SiteCreator` logic - what happens when the first user logs in.
        """

        from horus.interfaces import IActivationClass
        from horus.interfaces import IUserClass

        from websauna.system.user import models
        from websauna.system.model.meta import Base
        from websauna.system.user.interfaces import IGroupModel, IUserModel, ISiteCreator
        from websauna.system.user.usermixin import SiteCreator
        from websauna.system.user.userregistry import DefaultEmailBasedUserRegistry
        from websauna.system.user.interfaces import IActivationModel, IUserRegistry

        attach_model_to_base(models.User, Base)
        attach_model_to_base(models.Group, Base)
        attach_model_to_base(models.Activation, Base)
        attach_model_to_base(models.UserGroup, Base)

        # Mark active user and group class
        registry = self.config.registry
        registry.registerUtility(models.User, IUserModel)
        registry.registerUtility(models.Group, IGroupModel)
        registry.registerUtility(models.Activation, IActivationModel)

        # TODO: Legacy Horus compatibiltiy
        registry.registerUtility(models.User, IUserClass)

        site_creator = SiteCreator()
        registry.registerUtility(site_creator, ISiteCreator)

        # TODO: Get rid of Horus
        registry.registerUtility(models.Activation, IActivationClass)
        registry.registerAdapter(factory=DefaultEmailBasedUserRegistry, required=(IRequest,), provided=IUserRegistry)