Esempio n. 1
0
    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
Esempio n. 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(), [])
Esempio n. 3
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(), [])
Esempio n. 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)
Esempio n. 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)
Esempio n. 6
0
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')
Esempio n. 7
0
# 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")
Esempio n. 8
0
# 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")
Esempio n. 9
0
def setupInterfaces(test):
    provideInterface('', IOrganization)
    provideInterface('', IProject)
    provideInterface('', IStudent)
    provideInterface('', IMentor)
Esempio n. 10
0
 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)
Esempio n. 11
0
 def _callFUT(self, *args, **kw):
     from zope.component.interface import provideInterface
     return provideInterface(*args, **kw)
Esempio n. 12
0
def setupInterfaces(test):
    provideInterface('', IOptimizedClass)
    provideInterface('', IUnOptimizedClass)
    provideInterface('', IHalfOptimizedClass)
Esempio n. 13
0
 def setUp(self):
     obj = Item('obj')
     self.helpers = self._makeOne(obj, DummySetupEnviron())
     provideAdapter(MarkerInterfacesAdapter, (IItem, ))
     provideInterface('', IDummyMarker)
Esempio n. 14
0
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)
Esempio n. 15
0
def setupInterfaces(test):
    provideInterface('', IOptimizedClass)
    provideInterface('', IUnOptimizedClass)
    provideInterface('', IHalfOptimizedClass)
 def _callFUT(self, *args, **kw):
     from zope.component.interface import provideInterface
     return provideInterface(*args, **kw)