コード例 #1
0
 def testExpressionType(self):
     xmlconfig(StringIO(template % (
         """
         <tales:expressiontype
           name="test"
           handler="zope.app.pagetemplate.tests.test_directives.Handler"
           />
         """
         )))
     self.assert_("test" in Engine.getTypes())
     self.assert_(Handler is Engine.getTypes()['test'])
コード例 #2
0
ファイル: tests.py プロジェクト: Zojax/zojax.formatter
def setUp(test):
    setup.placefulSetUp(True)
    setup.setUpTraversal()
    setUpControlPanel()

    Engine.registerType(u'formatter', FormatterExpression)
    TrustedEngine.registerType(u'formatter', FormatterExpression)

    provideAdapter(dformatter.DateFormatterFactory, name='date')
    provideAdapter(dtformatter.DatetimeFormatterFactory, name='dateTime')
    provideAdapter(
        fancydatetime.FancyDatetimeFormatterFactory, name='fancyDatetime')
    provideAdapter(
        humandatetime.HumanDatetimeFormatterFactory, name='humanDatetime')
    provideAdapter(timeformatter.TimeFormatterFactory, name='time')
コード例 #3
0
ファイル: menumeta.py プロジェクト: wpjunior/proled
    def subMenuItem(
        self,
        _context,
        submenu,
        title,
        description=u"",
        action=u"",
        icon=None,
        filter=None,
        permission=None,
        extra=None,
        order=0,
    ):

        if filter is not None:
            filter = Engine.compile(filter)

        if order == 0:
            order = _order_counter.get(self.for_, 1)
            _order_counter[self.for_] = order + 1

        factory = MenuItemFactory(
            BrowserSubMenuItem,
            title=title,
            description=description,
            icon=icon,
            action=action,
            filter=filter,
            permission=permission,
            extra=extra,
            order=order,
            _for=self.for_,
            submenuId=submenu,
        )
        adapter(_context, (factory,), self.menuItemType, (self.for_, self.layer), name=title)
コード例 #4
0
ファイル: menumeta.py プロジェクト: bendavis78/zope
    def subMenuItem(self, _context, submenu, title, description=u'',
                    action=u'', icon=None, filter=None, permission=None,
                    extra=None, order=0, item_class=None):

        if filter is not None:
            filter = Engine.compile(filter)

        if permission is None:
            permission = self.permission

        if order == 0:
            order = _order_counter.get(self.for_, 1)
            _order_counter[self.for_] = order + 1

        if item_class is None:
            item_class = self.subMenuItemClass

        if not IBrowserSubMenuItem.implementedBy(item_class):
            raise ValueError("Item class (%s) must implement IBrowserSubMenuItem" % item_class)

        factory = MenuItemFactory(
            item_class,
            title=title, description=description, icon=icon, action=action,
            filter=filter, permission=permission, extra=extra, order=order,
            _for=self.for_, submenuId=submenu)
        adapter(_context, (factory,), self.menuItemType,
                (self.for_, self.layer), name=title)
コード例 #5
0
    def available(self):
        """See zope.app.publisher.interfaces.browser.IBrowserMenuItem"""
        # Make sure we have the permission needed to access the menu's action
        if self.permission is not None:
            # If we have an explicit permission, check that we
            # can access it.
            if not checkPermission(self.permission, self.context):
                return False

        elif self.action != u'':
            # Otherwise, test access by attempting access
            path = self.action
            l = self.action.find('?')
            if l >= 0:
                path = self.action[:l]

            traverser = PublicationTraverser()
            try:
                view = traverser.traverseRelativeURL(self.request,
                                                     self.context, path)
            except (Unauthorized, Forbidden, LookupError):
                return False
            else:
                # we're assuming that view pages are callable
                # this is a pretty sound assumption
                if not canAccess(view, '__call__'):
                    return False

        # Make sure that we really want to see this menu item
        if self.filter is not None:

            try:
                include = self.filter(
                    Engine.getContext(
                        context=self.context,
                        nothing=None,
                        request=self.request,
                        modules=sys.modules,
                    ))
            except Unauthorized:
                return False
            else:
                if not include:
                    return False

        return True
コード例 #6
0
    def available(self):
        """See zope.app.publisher.interfaces.browser.IBrowserMenuItem"""
        # Make sure we have the permission needed to access the menu's action
        if self.permission is not None:
            # If we have an explicit permission, check that we
            # can access it.
            if not checkPermission(self.permission, self.context):
                return False

        elif self.action != u'':
            # Otherwise, test access by attempting access
            path = self.action
            l = self.action.find('?')
            if l >= 0:
                path = self.action[:l]

            traverser = PublicationTraverser()
            try:
                view = traverser.traverseRelativeURL(
                    self.request, self.context, path)
            except (Unauthorized, Forbidden, LookupError):
                return False
            else:
                # we're assuming that view pages are callable
                # this is a pretty sound assumption
                if not canAccess(view, '__call__'):
                    return False

        # Make sure that we really want to see this menu item
        if self.filter is not None:

            try:
                include = self.filter(Engine.getContext(
                    context = self.context,
                    nothing = None,
                    request = self.request,
                    modules = sys.modules,
                    ))
            except Unauthorized:
                return False
            else:
                if not include:
                    return False

        return True
コード例 #7
0
def clear():
    Engine.__init__()
    _Engine(Engine)
    TrustedEngine.__init__()
    _TrustedEngine(TrustedEngine)
コード例 #8
0
def registerType(name, handler):
    Engine.registerType(name, handler)
    TrustedEngine.registerType(name, handler)