コード例 #1
0
ファイル: resources.py プロジェクト: silvacms/silva.fanstatic
    def solve_dependencies(self, interface, library, resources):
        """This solve dependencies for resources mapped to an
        interface in the given library. When solved, a fanstatic
        resource is created and registered.
        """
        dependencies = []
        try:
            need_parent = None
            parents = list_base_layers(interface)
            while True:
                dependency = parents.send(need_parent)
                identifier = dependency.__identifier__
                if identifier in self.resources:
                    if identifier in INTERFACES_RESOURCES:
                        fanstatic_dependency = INTERFACES_RESOURCES[identifier]
                    else:
                        fanstatic_dependency = self.solve_dependencies(*self.resources[identifier])
                    if fanstatic_dependency is not None:
                        dependencies.insert(0, fanstatic_dependency)
                    need_parent = False
                else:
                    need_parent = True
        except StopIteration:
            fanstatic_resource = get_fanstatic_resource(library, resources, dependencies)
            context = silvaconf.only_for.bind().get(interface)
            factory = create_resource_subscriber(fanstatic_resource)

            provideSubscriptionAdapter(factory, (interface, context), ISubscribedResource)
            provideInterface('', interface)
            INTERFACES_RESOURCES[interface.__identifier__] = fanstatic_resource
            return fanstatic_resource
        return None
コード例 #2
0
    def test_editview(self):
        obj = SimpleContent('foo', 'Foo').__of__(self.app.test_folder_1_)
        view = EditView(obj, {})

        # Test state before making any changes
        self.assertTrue(view.context.aq_inner is obj)
        self.assertEqual(view.request, {})
        self.assertEqual(view.getAvailableInterfaceNames(), [])
        self.assertEqual(view.getDirectlyProvidedNames(), [])
        self.assertIn({'name': ISimpleContentName}, view.getInterfaceNames())

        # Try to add a marker interface that doesn't exist
        self.assertRaises(ComponentLookupError, view.update,
                          ('__main__.IFooMarker', ), ())

        # Now create the marker interface and try again
        provideInterface('', IFooMarker)
        self.assertIn({'name': IFooMarkerName},
                      view.getAvailableInterfaceNames())
        self.assertEqual(view.getDirectlyProvidedNames(), [])

        # And try again to add it to the object
        view.update((IFooMarkerName, ), ())
        self.assertEqual(view.getAvailableInterfaceNames(), [])
        self.assertIn({'name': IFooMarkerName},
                      view.getDirectlyProvidedNames())

        # And remove it again
        view.update((), (IFooMarkerName, ))
        self.assertIn({'name': IFooMarkerName},
                      view.getAvailableInterfaceNames())
        self.assertEqual(view.getDirectlyProvidedNames(), [])
コード例 #3
0
ファイル: test_marker.py プロジェクト: zopefoundation/Zope
    def test_editview(self):
        obj = SimpleContent('foo', 'Foo').__of__(self.app.test_folder_1_)
        view = EditView(obj, {})

        # Test state before making any changes
        self.assertTrue(view.context.aq_inner is obj)
        self.assertEqual(view.request, {})
        self.assertEqual(view.getAvailableInterfaceNames(), [])
        self.assertEqual(view.getDirectlyProvidedNames(), [])
        self.assertIn({'name': ISimpleContentName}, view.getInterfaceNames())

        # Try to add a marker interface that doesn't exist
        self.assertRaises(ComponentLookupError, view.update,
                          ('__main__.IFooMarker',), ())

        # Now create the marker interface and try again
        provideInterface('', IFooMarker)
        self.assertIn({'name': IFooMarkerName},
                      view.getAvailableInterfaceNames())
        self.assertEqual(view.getDirectlyProvidedNames(), [])

        # And try again to add it to the object
        view.update((IFooMarkerName,), ())
        self.assertEqual(view.getAvailableInterfaceNames(), [])
        self.assertIn({'name': IFooMarkerName},
                      view.getDirectlyProvidedNames())

        # And remove it again
        view.update((), (IFooMarkerName,))
        self.assertIn({'name': IFooMarkerName},
                      view.getAvailableInterfaceNames())
        self.assertEqual(view.getDirectlyProvidedNames(), [])
コード例 #4
0
 def setUp(self):
     from zope.component import provideAdapter
     from zope.component.interface import provideInterface
     from OFS.interfaces import IItem
     from Products.Five.utilities.marker import MarkerInterfacesAdapter
     from Products.GenericSetup.testing import IDummyMarker
     provideAdapter(MarkerInterfacesAdapter, (IItem, ))
     provideInterface('', IDummyMarker)
コード例 #5
0
 def setUp(self):
     from zope.component import provideAdapter
     from zope.component.interface import provideInterface
     from OFS.interfaces import IItem
     from Products.Five.utilities.marker import MarkerInterfacesAdapter
     from Products.GenericSetup.testing import IDummyMarker
     provideAdapter(MarkerInterfacesAdapter, (IItem, ))
     provideInterface('', IDummyMarker)
コード例 #6
0
ファイル: tests.py プロジェクト: Zojax/zojax.content.type
def setUp(test):
    placelesssetup.setUp(test)
    provideInterface("Test content types",
                     ITestContentType, interfaces.IContentTypeType)
    setUpContents()
    component.provideAdapter(
        AnnotationPrincipalPermissionManager, (interface.Interface,))
    component.provideAdapter(TitleBasedNameChooser)
    component.provideHandler(order.itemMoved)
    component.provideAdapter(order.Reordable, provides=interfaces.IOrder)
    component.provideAdapter(ContentSearchableText)
    setup.setUpTestAsModule(test, 'zojax.content.TESTS')
コード例 #7
0
ファイル: interfaces.py プロジェクト: ilshad/tacklets
# 2010 Ilshad Khabibullin <*****@*****.**>

from zope.schema import Choice
from zope.interface import Interface
from zope.component.interface import provideInterface
from zope.publisher.interfaces.browser import IBrowserSkinType
from tackle.skin.interfaces import ISkin


class ITheming(Interface):
    """Theming schema"""

    theme = Choice(title=u"Style theme", default=ISkin, vocabulary="Themes")


class ITheme(IBrowserSkinType):
    """If an layer skin provides this interface type
    then that skin are considered style"""


provideInterface("Tackle", ISkin, ITheme)


class IDefaultThemePersistentConfig(Interface):
    """Persistent config defines default theme"""

    theme = Choice(title=u"Style theme", default=ISkin, vocabulary="Themes")
コード例 #8
0
ファイル: interfaces.py プロジェクト: ilshad/tacklets
# 2010 Ilshad Khabibullin <*****@*****.**>

from zope.schema import Choice
from zope.interface import Interface
from zope.component.interface import provideInterface
from zope.publisher.interfaces.browser import IBrowserSkinType
from tackle.skin.interfaces import ISkin


class ITheming(Interface):
    """Theming schema"""

    theme = Choice(title=u"Style theme", default=ISkin, vocabulary="Themes")


class ITheme(IBrowserSkinType):
    """If an layer skin provides this interface type
    then that skin are considered style"""


provideInterface('Tackle', ISkin, ITheme)


class IDefaultThemePersistentConfig(Interface):
    """Persistent config defines default theme"""

    theme = Choice(title=u"Style theme", default=ISkin, vocabulary="Themes")
コード例 #9
0
ファイル: utils.py プロジェクト: bendavis78/zope
def setupInterfaces(test):
    provideInterface('', IOrganization)
    provideInterface('', IProject)
    provideInterface('', IStudent)
    provideInterface('', IMentor)
コード例 #10
0
ファイル: installer.py プロジェクト: silvacms/silva.core.conf
 def __init__(self, name=None, interface=None):
     super(DefaultInstaller, self).__init__()
     assert interface is not None, u"You must provide an interface"
     self._interface = interface
     provideInterface('', self._interface)
コード例 #11
0
ファイル: test_interface.py プロジェクト: dcredpanda/atsv
 def _callFUT(self, *args, **kw):
     from zope.component.interface import provideInterface
     return provideInterface(*args, **kw)
コード例 #12
0
def setupInterfaces(test):
    provideInterface('', IOptimizedClass)
    provideInterface('', IUnOptimizedClass)
    provideInterface('', IHalfOptimizedClass)
コード例 #13
0
ファイル: test_utils.py プロジェクト: bendavis78/zope
 def setUp(self):
     obj = Item('obj')
     self.helpers = self._makeOne(obj, DummySetupEnviron())
     provideAdapter(MarkerInterfacesAdapter, (IItem, ))
     provideInterface('', IDummyMarker)
コード例 #14
0
ファイル: zcml.py プロジェクト: Zojax/zojax.layout
def pageletTypeDirective(_context, name, interface):
    if interface is not IPagelet and interface.isOrExtends(IPublishTraverse):
        raise ConfigurationError("Can't use IPublishTraverse as base for pagelet type")

    provideInterface(name, interface, IPageletType)
コード例 #15
0
ファイル: utils_opt.py プロジェクト: agroszer/ocql
def setupInterfaces(test):
    provideInterface('', IOptimizedClass)
    provideInterface('', IUnOptimizedClass)
    provideInterface('', IHalfOptimizedClass)
コード例 #16
0
 def _callFUT(self, *args, **kw):
     from zope.component.interface import provideInterface
     return provideInterface(*args, **kw)