Ejemplo n.º 1
0
def setUpZPT(test):
    setUp(test)

    # register provider TALES
    from zope.browserpage import metaconfigure
    from zope.contentprovider import tales
    metaconfigure.registerType('provider', tales.TALESProviderExpression)
Ejemplo n.º 2
0
def setUpZPT(test):
    z3c.form.testing.setUpZPT(test)
    from zope.browserpage.metaconfigure import registerType
    from zope.contentprovider.tales import TALESProviderExpression
    from z3c.macro.tales import MacroExpression
    registerType('macro', MacroExpression)
    registerType('provider', TALESProviderExpression)
Ejemplo n.º 3
0
def setUp(test):
    root = siteSetUp(True)
    test.globs['root'] = root

    from zope.traversing.testing import setUp
    setUp()

    from zope.browserpage import metaconfigure
    from zope.contentprovider import tales
    metaconfigure.registerType('provider', tales.TALESProviderExpression)

    zope.security.management.newInteraction()
    zope.security.management.getInteraction().add(TestParticipation())
Ejemplo n.º 4
0
def setUp(test):
    cleanup.setUp()
    eventtesting.setUp()

    from zope.browserpage.metaconfigure import registerType
    from zope.contentprovider import tales
    registerType('provider', tales.TALESProviderExpression)

    # Make sure we are always reloading page template files ;-)
    global mtime_func
    mtime_func = os.path.getmtime
    def number(x):
        global counter
        counter += 1
        return counter
    os.path.getmtime = number
Ejemplo n.º 5
0
def setUp(test):
    cleanup.setUp()
    eventtesting.setUp()
    traversingSetUp()

    # resource namespace setup
    from zope.traversing.interfaces import ITraversable
    from zope.traversing.namespace import resource
    zope.component.provideAdapter(
        resource, (None,), ITraversable, name = "resource")
    zope.component.provideAdapter(
        resource, (None, None), ITraversable, name = "resource")

    from zope.browserpage import metaconfigure
    from zope.contentprovider import tales
    metaconfigure.registerType('provider', tales.TALESProviderExpression)
Ejemplo n.º 6
0
def doctestSetUp(test):
    cleanup.setUp()
    eventtesting.setUp()
    traversingSetUp()

    # resource namespace setup
    from zope.traversing.interfaces import ITraversable
    from zope.traversing.namespace import resource
    zope.component.provideAdapter(resource, (None, ),
                                  ITraversable,
                                  name="resource")
    zope.component.provideAdapter(resource, (None, None),
                                  ITraversable,
                                  name="resource")

    from zope.browserpage import metaconfigure
    from zope.contentprovider import tales
    metaconfigure.registerType('provider', tales.TALESProviderExpression)
Ejemplo n.º 7
0
def setUp(test):
    cleanup.setUp()
    eventtesting.setUp()

    from zope.browserpage.metaconfigure import registerType
    from zope.contentprovider import tales
    registerType('provider', tales.TALESProviderExpression)

    # Make sure we are always reloading page template files ;-)
    global mtime_func
    mtime_func = os.path.getmtime

    def number(x):
        global counter
        counter += 1
        return counter

    os.path.getmtime = number
Ejemplo n.º 8
0
def setUp(test):
    test.globs = {'root': siteSetUp(True)}

    traversing.setUp()

    from zope.browserpage import metaconfigure
    metaconfigure.registerType('macro', z3c.macro.tales.MacroExpression)

    zope.component.provideAdapter(ObjectCopier, (IContained,), IObjectCopier)
    zope.component.provideAdapter(ObjectMover, (IContained,), IObjectMover)
    zope.component.provideAdapter(ContainerItemRenamer, (IContainer,),
        IContainerItemRenamer)

    zope.component.provideAdapter(PrincipalClipboard, (IAnnotations,),
        IPrincipalClipboard)
    # use None as principal
    zope.component.provideAdapter(PrincipalAnnotations, (None,),
        IAnnotations)

    # dublin core stub adapter
    zope.component.provideAdapter(z3c.table.testing.DublinCoreAdapterStub)

    # value adapter
    zope.component.provideAdapter(z3c.contents.value.SearchableValues)
Ejemplo n.º 9
0
# -*- coding: utf-8 -*-
from __future__ import absolute_import, unicode_literals
MANY = 48
#lint:disable
# from . import memberStatusActionsContentProvider
#lint:enable
from zope.browserpage import metaconfigure
from zope.tales.tales import RegistrationError
from zope.contentprovider import tales
try:
    metaconfigure.registerType('provider', tales.TALESProviderExpression)
except RegistrationError:
    # Almost certainly registered somewhere else
    pass
from zope.i18nmessageid import MessageFactory
GSMessageFactory = MessageFactory('gs.group.member.manage')
Ejemplo n.º 10
0
def setUp(test):
    test.globs = {'root': setup.placefulSetUp(True)}

    metaconfigure.registerType('macro', z3c.macro.tales.MacroExpression)
    z3c.table.testing.setUpAdapters()
Ejemplo n.º 11
0
def setUpZPT(test):
    setUp(test)
    from zope.browserpage import metaconfigure
    metaconfigure.registerType('macro', z3c.macro.tales.MacroExpression)
Ejemplo n.º 12
0
def setUp(test=None):
    """Set up the test fixture for schooltool.app.browser doctests.

    Performs what is called a "placeless setup" in the Zope 3 world, then sets
    up annotations, relationships, and registers widgets as views for some
    schema fields.

    In effect, duplicates a subset of ZCML configuration -- just enough to
    actually render our page templates in unit tests.
    """
    setup.placefulSetUp()
    setup.setUpAnnotations()
    setup.setUpTraversal()
    # relationships
    setUpRelationships()
    # widgets
    ztapi.browserViewProviding(IPassword, PasswordWidget, IInputWidget)
    ztapi.browserViewProviding(ITextLine, TextWidget, IInputWidget)
    ztapi.browserViewProviding(IText, TextAreaWidget, IInputWidget)
    ztapi.browserViewProviding(IBytes, BytesWidget, IInputWidget)
    ztapi.browserViewProviding(IBool, CheckBoxWidget, IInputWidget)
    ztapi.browserViewProviding(IDate, DateWidget, IInputWidget)
    ztapi.browserViewProviding(IInt, IntWidget, IInputWidget)
    ztapi.browserViewProviding(IChoice, ChoiceInputWidget, IInputWidget)
    ztapi.browserViewProviding(ICollection, CollectionInputWidget, IInputWidget)

    ztapi.provideMultiView((IChoice, IIterableVocabulary), IBrowserRequest,
                           IInputWidget, '', DropdownWidget)

    ztapi.provideMultiView((ISet, IChoice), IBrowserRequest,
                           IInputWidget, '', ChoiceCollectionInputWidget)
    ztapi.provideMultiView((IList, IChoice), IBrowserRequest,
                           IInputWidget, '', ChoiceCollectionInputWidget)
    ztapi.provideMultiView((IList, IVocabularyTokenized), IBrowserRequest,
                           IInputWidget, '', OrderedMultiSelectWidget)
    # XXX MultiSelectWidget doesn't work with sets :/
    #     http://www.zope.org/Collectors/Zope3-dev/360
    ztapi.provideMultiView((ISet, IIterableVocabulary), IBrowserRequest,
                           IInputWidget, '', MultiSelectWidget)

    # errors in forms
    ztapi.browserViewProviding(IWidgetInputError, WidgetInputErrorView,
                               IWidgetInputErrorView)


    # Now, the question is: does the speed of the tests run with the
    # setup below justify this complex setup that duplicates the ZCML?
    # For now, I say yes. -- not mg, perhaps alga or gintas

    # ++view++
    ztapi.provideView(None, None, ITraversable, 'view', view)
    ztapi.provideView(None, None, ITraversable, 'resource', resource)

    # schooltool: namespace in tal
    provideAdapter(SchoolToolAPI, (None,), IPathAdapter, 'schooltool')

    # sortby: namespace in tal
    provideAdapter(SortBy, (None,), IPathAdapter, 'sortby')

    # standard_macros, schooltool_macros and schooltool_navigation
    ztapi.browserView(None, 'standard_macros', StandardMacros)
    ztapi.browserView(None, 'view_macros',
                      SimpleViewClass("../../skin/templates/view_macros.pt"))

    ztapi.browserView(None, 'schooltool_macros', SchoolToolMacros)
    ztapi.browserView(None, 'calendar_macros',
                      SimpleViewClass("./templates/calendar_macros.pt"))
    ztapi.browserView(None, 'generic_macros',
                      SimpleViewClass("../../skin/templates/generic_macros.pt"))

    # form macros
    ztapi.browserView(None, 'form_macros', FormMacros)
    import zope.formlib
    base = zope.formlib.__path__[0]
    ztapi.browserView(None, 'widget_macros',
                      SimpleViewClass(os.path.join(base, 'widget_macros.pt')))

    # resources
    class ResourceStub:
        def __init__(self, request):
            self.request = request
        def __getitem__(self, key):
            return ResourceStub(self.request)
        def __call__(self):
            return "a dummy resource"

    for name in ['layout.css', 'schooltool.css', 'schooltool.js',
                 'next.png', 'prev.png', 'favicon.ico',
                 'print.css', 'jquery.js',
                 'zonki-regular.png']:
        ztapi.browserResource(name, ResourceStub)

    # menus
    ztapi.browserView(None, 'view_get_menu', MenuAccessView)
    provideUtility(BrowserMenuStub('schooltool_actions'), IBrowserMenu,
                   'schooltool_actions')

    # `provider` TALES namespaces
    from zope.browserpage import metaconfigure
    from zope.contentprovider import tales
    metaconfigure.registerType('provider', tales.TALESProviderExpression)

    # viewlet manager registrations
    from zope.viewlet import manager
    from schooltool import skin
    name = 'schooltool.Header'
    provideAdapter(
        manager.ViewletManager(name, skin.IHeaderManager),
        (Interface, IDefaultBrowserLayer, IBrowserView),
        skin.IHeaderManager,
        name=name)

    name = 'schooltool.JavaScript'
    provideAdapter(
        manager.ViewletManager(name, skin.IJavaScriptManager),
        (Interface, IDefaultBrowserLayer, IBrowserView),
        skin.IJavaScriptManager,
        name=name)

    name = 'schooltool.CSS'
    provideAdapter(
        manager.ViewletManager(name, skin.ICSSManager),
        (Interface, IDefaultBrowserLayer, IBrowserView),
        skin.ICSSManager,
        name=name)

    name = 'schooltool.MenuBar'
    provideAdapter(
        manager.ViewletManager(name, skin.skin.IMenuBarMenuManager),
        (Interface, IDefaultBrowserLayer, IBrowserView),
        skin.skin.IMenuBarMenuManager,
        name=name)

    name = 'schooltool.NavigationMenu'
    provideAdapter(
        manager.ViewletManager(name, skin.skin.INavigationManager),
        (Interface, IDefaultBrowserLayer, IBrowserView),
        skin.skin.INavigationManager,
        name=name)

    name = 'schooltool.ActionsMenu'
    provideAdapter(
        manager.ViewletManager(name, skin.skin.IActionMenuManager),
        (Interface, IDefaultBrowserLayer, IBrowserView),
        skin.skin.IActionMenuManager,
        name=name)