예제 #1
0
    def __init__(self, request):
        self.request = request
        self.__parent__ = None
        self.title = 'Admin'

        if self.__admin_menu__:
            admin_menu = self.__admin_menu__
        else:
            models = request.registry.getUtilitiesFor(IModel)
            admin_menu = sorted([name for name, ob in models])
        admin_menu = [
            get_model_config(self.request, name)
            for name in admin_menu]

        request.route_name = self.__fa_route_name__
        request.session_factory = self.__session_factory__
        request.query_factory = self.__query_factory__
        request.fa_url = self.fa_url
        request.model_instance = None
        request.model_class = None
        request.model_name = None
        request.model_id = None
        request.relation = None
        request.format = 'html'
        request.admin_menu = admin_menu

        request.current_user = get_current_user(self.request)

        request.actions = actions.RequestActions()

        from js.bootstrap import bootstrap
        bootstrap.need()
예제 #2
0
    def __init__(self, request, name, parent):
        self.request = request
        self.__name__ = name
        self.__parent__ = parent

        model_class = self.request.registry.queryUtility(IModel, name=name)
        assert model_class

        config = get_model_config(self.request, name)
        self.title = config.get("title", name)

        self.request.model_name = name
        self.request.model_class = model_class
예제 #3
0
    def __init__(self, request, name, parent):
        self.request = request
        self.__name__ = name
        self.__parent__ = parent

        # request.model_class and request.model_name are already set
        model_class = request.model_class
        assert model_class is not None

        config = get_model_config(self.request, request.model_name)
        self.title = config.get("title", request.model_name)

        instance = self.prepare_instance(name)
        if instance is None:
            raise KeyError()

        self.request.model_id = name
        self.request.model_instance = instance