Пример #1
0
    def __getitem__(self, key):
        for id, factory in ptahcms.get_app_factories().items():
            if factory.name == key:
                request = self.request
                request.request_iface = request.registry.getUtility(
                    IRouteRequest, name=MANAGE_APP_ROUTE)
                request.app_factory = factory
                app = factory()
                app.__parent__ = self
                app.__root_path__ = '/ptah-manage/apps/%s/'%app.__name__
                return app

        raise KeyError(key)
Пример #2
0
def cmsContent(request, app='', uri=None, action='', *args):
    name = getattr(request, 'subpath', ('content',))[0]
    if ':' not in name:
        if not action:
            action = uri or ''
        uri = app
        app = ''

    content = None

    appfactory = ptahcms.get_app_factories().get(app)
    if appfactory is not None:
        root = appfactory(request)
        request.root = root

        if not uri:
            content = root

    if content is None:
        content = load(uri)

    adapters = request.registry.adapters

    action = adapters.lookup(
        (IRestActionClassifier, providedBy(content)),
        IRestAction, name=action, default=None)

    if action:
        if app:
            request.environ['SCRIPT_NAME'] = '%s/content:%s/'%(
                request.environ['SCRIPT_NAME'], app)
        else:
            request.environ['SCRIPT_NAME'] = '%s/content/'%(
                request.environ['SCRIPT_NAME'])

        ptah.check_permission(action.permission, content, request, True)
        res = action.callable(content, request, *args)
        if not res: # pragma: no cover
            res = {}
        return res

    raise NotFound()
Пример #3
0
def cmsApplications(request, *args):
    apps = []

    for name, factory in ptahcms.get_app_factories().items():
        root = factory()

        try:
            info = wrap(root).info()
        except (AttributeError, TypeException):
            continue

        info['__mount__'] = name
        if name:
            info['__link__'] = '%s/content:%s/%s/' % (request.application_url,
                                                      name, root.__uri__)
        else:
            info['__link__'] = '%s/content/%s/' % (request.application_url,
                                                   root.__uri__)
        apps.append(info)

    return apps
Пример #4
0
def cmsApplications(request, *args):
    apps = []

    for name, factory in ptahcms.get_app_factories().items():
        root = factory()

        try:
            info = wrap(root).info()
        except (AttributeError, TypeException):
            continue

        info['__mount__'] = name
        if name:
            info['__link__'] = '%s/content:%s/%s/'%(
                request.application_url, name, root.__uri__)
        else:
            info['__link__'] = '%s/content/%s/'%(
                request.application_url, root.__uri__)
        apps.append(info)

    return apps
Пример #5
0
    def update(self):
        factories = []
        for factory in ptahcms.get_app_factories().values():
            factories.append((factory.title, factory))

        self.factories = [f for _t, f in sorted(factories)]
Пример #6
0
 def available(self):
     return bool(ptahcms.get_app_factories())
Пример #7
0
    def update(self):
        factories = []
        for factory in ptahcms.get_app_factories().values():
            factories.append((factory.title, factory))

        self.factories = [f for _t, f in sorted(factories)]
Пример #8
0
 def available(self):
     return bool(ptahcms.get_app_factories())