예제 #1
0
def load_filesystem_bundle(bundle_path, bundle_name, default_parent_name=None):
    """
    Load a bundle from the filesystem:

    * register its components
    * regiser a writer, if writing is allowed
    * register a reloader

    :param bundle_path: Path to bundle folder that contains a
                        "templates" sub-folder.
    :param bundle_name: Name of the bundle where registration will
                        happen.
    :param default_parent_name: Name of the parent bundle to set on the
                                loaded bundle, if no parent is defined in
                                the `bundle.cfg` file.
    """
    gsm = getGlobalSiteManager()

    cfg = _read_bundle_cfg(bundle_path)
    try:
        parent_name = cfg.get('bundle', 'parent-bundle')
    except ConfigParser.NoOptionError:
        parent_name = default_parent_name

    bundle = bundles.get(bundle_name)
    if parent_name is not None:
        bundle.set_parent(bundles.get(parent_name))

    loader = FilesystemBundleLoader(bundle_name, bundle_path)
    loader.load_all()
    gsm.registerUtility(loader, name=bundle_name)

    writer = FilesystemTemplateWriter(loader.templates_path)
    gsm.registerUtility(writer, name=bundle_name)
예제 #2
0
    def test_parent_bundle(self):
        self.bundle_names.append("CHM-Foo")

        from naaya.core import fsbundles
        fsbundles.load_filesystem_bundle(self.bundle_path, "CHM-Foo", "CHM")
        foo = bundles.get("CHM-Foo")
        self.assertTrue(foo.get_parent() is bundles.get("CHM"), "Wrong parent")
예제 #3
0
def rstk_method_directive(_context, handler, name=None,
                          context=False, bundle='Naaya', getattrPatch=False):
    if name is None:
        name = handler.__name__

    if not context:
        orig_handler = handler
        handler = lambda ctx, *args, **kwargs: orig_handler(*args, **kwargs)

    bundles.get(bundle).registerUtility(handler, IRstkMethod, name)

    if getattrPatch:
        import warnings
        from naaya.core.zope2util import RestrictedToolkit
        msg = ("RestrictedToolkit method %(name)r should be accessed as "
               "rstk[%(name)r] instead of rstk.%(name)s" % {'name': name})
        to_warn = [1]

        def compatibility_handler(*args, **kwargs):
            if to_warn:
                warnings.warn(msg, DeprecationWarning)
                to_warn[:] = []

            return handler(*args, **kwargs)

        setattr(RestrictedToolkit, name, compatibility_handler)
예제 #4
0
    def test_parent_bundle(self):
        self.bundle_names.append("CHM-Foo")

        from naaya.core import fsbundles
        fsbundles.load_filesystem_bundle(self.bundle_path, "CHM-Foo", "CHM")
        foo = bundles.get("CHM-Foo")
        self.assertTrue(foo.get_parent() is bundles.get("CHM"), "Wrong parent")
예제 #5
0
def rstk_method_directive(_context,
                          handler,
                          name=None,
                          context=False,
                          bundle='Naaya',
                          getattrPatch=False):
    if name is None:
        name = handler.__name__

    if not context:
        orig_handler = handler
        handler = lambda ctx, *args, **kwargs: orig_handler(*args, **kwargs)

    bundles.get(bundle).registerUtility(handler, IRstkMethod, name)

    if getattrPatch:
        import warnings
        from naaya.core.zope2util import RestrictedToolkit
        msg = ("RestrictedToolkit method %(name)r should be accessed as "
               "rstk[%(name)r] instead of rstk.%(name)s" % {
                   'name': name
               })
        to_warn = [1]

        def compatibility_handler(*args, **kwargs):
            if to_warn:
                warnings.warn(msg, DeprecationWarning)
                to_warn[:] = []

            return handler(*args, **kwargs)

        setattr(RestrictedToolkit, name, compatibility_handler)
예제 #6
0
    def test_parent_bundle_from_cfg_file(self):
        self.bundle_names.append("CHM-Foo")
        self.bundle_names.append("Bar")
        f = open(os.path.join(self.bundle_path, 'bundle.cfg'), 'wb')
        f.write("[bundle]\nparent-bundle = Bar\n")
        f.close()

        from naaya.core import fsbundles
        fsbundles.load_filesystem_bundle(self.bundle_path, "CHM-Foo")
        foo = bundles.get("CHM-Foo")
        self.assertTrue(foo.get_parent() is bundles.get("Bar"), "Wrong parent")
예제 #7
0
    def test_parent_bundle_from_cfg_file(self):
        self.bundle_names.append("CHM-Foo")
        self.bundle_names.append("Bar")
        f = open(os.path.join(self.bundle_path, 'bundle.cfg'), 'wb')
        f.write("[bundle]\nparent-bundle = Bar\n")
        f.close()

        from naaya.core import fsbundles
        fsbundles.load_filesystem_bundle(self.bundle_path, "CHM-Foo")
        foo = bundles.get("CHM-Foo")
        self.assertTrue(foo.get_parent() is bundles.get("Bar"), "Wrong parent")
예제 #8
0
    def test_get_parent(self):
        self.bundle_names.extend(["Foo", "Bar"])
        foo = bundles.get("Foo")
        bar = bundles.get("Bar")

        # no parent was set
        gsm = getGlobalSiteManager()
        self.assertTrue(foo.get_parent() is gsm)

        # some parent was set
        foo.set_parent(bar)
        self.assertTrue(foo.get_parent() is bar)
예제 #9
0
    def test_get_parent(self):
        self.bundle_names.extend(["Foo", "Bar"])
        foo = bundles.get("Foo")
        bar = bundles.get("Bar")

        # no parent was set
        gsm = getGlobalSiteManager()
        self.assertTrue(foo.get_parent() is gsm)

        # some parent was set
        foo.set_parent(bar)
        self.assertTrue(foo.get_parent() is bar)
예제 #10
0
    def test_customize_component(self):
        from zope import interface
        from zope.app.component.site import LocalSiteManager
        from naaya.component.interfaces import ICustomize

        class MyClassCustomizer(object):
            interface.implements(ICustomize)

            def __init__(self, target):
                self.target = target

            def customize(self, site_manager, name):
                site_manager.registerUtility(MyClass(color='red'), name=name)

        self.bundle_names.append('test-bundle')
        test_bundle = bundles.get('test-bundle')
        test_bundle.registerUtility(MyClass(color='green'), name='tomato')
        test_bundle.registerAdapter(MyClassCustomizer, [ITestUtil], ICustomize)

        site_manager = LocalSiteManager(None)
        site_manager.__bases__ = (test_bundle, )

        bundles.customize_utility(site_manager, ITestUtil, 'tomato')

        util = site_manager.getUtility(ITestUtil, name='tomato')
        self.assertEqual(util.color, 'red')
예제 #11
0
    def _update(self, portal):
        sm = portal.getSiteManager()

        if sm.__name__ == '++etc++site':
            sm.__name__ = 'database'
            self.log.info("Set name of local site manager to %r", sm.__name__)

        bundle = portal.get_bundle()
        portal_cls_name = portal.__class__.__name__

        if bundle is getGlobalSiteManager() or bundle.__name__ == 'CHM':
            bundle_name = bundle_for_site_cls.get(portal_cls_name, 'Naaya')
            bundle = bundles.get(bundle_name)
            portal.set_bundle(bundle)
            self.log.info("Portal bundle set to %r", bundle_name)
        else:
            self.log.info("Not changing portal bundle %r", bundle)

        forms_tool = portal.getFormsTool()
        for template in forms_tool.objectValues():
            name = template.getId()
            sm.registerUtility(template, ITemplate, name)
            self.log.info("Registered ITemplate %r", name)

        return True
    def _update(self, portal):
        sm = portal.getSiteManager()

        if sm.__name__ == "++etc++site":
            sm.__name__ = "database"
            self.log.info("Set name of local site manager to %r", sm.__name__)

        bundle = portal.get_bundle()
        portal_cls_name = portal.__class__.__name__

        if bundle is getGlobalSiteManager() or bundle.__name__ == "CHM":
            bundle_name = bundle_for_site_cls.get(portal_cls_name, "Naaya")
            bundle = bundles.get(bundle_name)
            portal.set_bundle(bundle)
            self.log.info("Portal bundle set to %r", bundle_name)
        else:
            self.log.info("Not changing portal bundle %r", bundle)

        forms_tool = portal.getFormsTool()
        for template in forms_tool.objectValues():
            name = template.getId()
            sm.registerUtility(template, ITemplate, name)
            self.log.info("Registered ITemplate %r", name)

        return True
예제 #13
0
def manage_addCHMSite(self,
                      id='',
                      title='',
                      lang=None,
                      google_api_keys=None,
                      load_glossaries=[],
                      bundle_name='CHM',
                      REQUEST=None):
    """ """
    if REQUEST is not None:
        # we'll need the SESSION later on; grab it early so we don't
        # get a ConflictError.
        REQUEST.SESSION
    ut = utils()
    id = ut.utCleanupId(id)
    if not id: id = PREFIX_SITE + ut.utGenRandomId(6)
    chm_site = CHMSite(id, title=title, lang=lang)
    chm_site.set_bundle(bundles.get(bundle_name))
    self._setObject(id, chm_site)
    chm_site = self._getOb(id)
    chm_site.loadDefaultData(load_glossaries, _get_skel_handler(bundle_name))

    if google_api_keys:
        engine = chm_site.getGeoMapTool()['engine_google']
        engine.api_keys = google_api_keys

    if REQUEST is not None:
        return self.manage_main(self, REQUEST, update_menu=1)
예제 #14
0
    def __init__(self, filename, _globals, name, bundle_name="Naaya"):
        PageTemplateFile.__init__(self, filename, _globals, __name__=name)

        #Register this template to a specific bundle
        bundle = bundles.get(bundle_name)
        bundle.registerUtility(self, ITemplate, name)
        self._bundle_name = bundle_name
예제 #15
0
    def test_customize_component(self):
        from zope import interface
        from zope.app.component.site import LocalSiteManager
        from naaya.component.interfaces import ICustomize

        class MyClassCustomizer(object):
            interface.implements(ICustomize)

            def __init__(self, target):
                self.target = target

            def customize(self, site_manager, name):
                site_manager.registerUtility(MyClass(color='red'), name=name)


        self.bundle_names.append('test-bundle')
        test_bundle = bundles.get('test-bundle')
        test_bundle.registerUtility(MyClass(color='green'), name='tomato')
        test_bundle.registerAdapter(MyClassCustomizer, [ITestUtil], ICustomize)

        site_manager = LocalSiteManager(None)
        site_manager.__bases__ = (test_bundle,)

        bundles.customize_utility(site_manager, ITestUtil, 'tomato')

        util = site_manager.getUtility(ITestUtil, name='tomato')
        self.assertEqual(util.color, 'red')
예제 #16
0
    def __init__(self, filename, _globals, name, bundle_name="Naaya"):
        PageTemplateFile.__init__(self, filename, _globals, __name__=name)

        #Register this template to a specific bundle
        bundle = bundles.get(bundle_name)
        bundle.registerUtility(self, ITemplate, name)
        self._bundle_name = bundle_name
예제 #17
0
    def filesystem_bundle_factory(site):
        def create_bundle():
            """ Create a writable bundle on demand. """
            site_path = site.getPhysicalPath()
            if site_path[0] == '': # remove first empty path
                site_path = site_path[1:]
            bundle_name = name_prefix + '-'.join(site_path)

            site_parent = get_site_parent(site)
            parent_bundle = bundles.get(parent_name)
            if site_parent is not parent_bundle:
                raise ValueError("Site has wrong parent, %r != %r" %
                                 (site_parent, parent_bundle))
            bundle_path = os.path.join(bundles_dir, bundle_name + ".bundle")
            log.info("Creating bundle %r at %r", bundle_name, bundle_path)
            try:
                os.makedirs(bundle_path)
            except OSError, e:
                raise ValueError("Filesystem bundle %r already exists (%s)" %
                                 (bundle_name, e))

            cfg_file = open(os.path.join(bundle_path, 'bundle.cfg'), 'wb')
            cfg_file.write("[bundle]\nparent-bundle = %s\n" % parent_name)
            cfg_file.close()

            # TODO in ZEO configurations we need to notify the other instances
            load_filesystem_bundle(bundle_path, bundle_name, parent_name)
            new_bundle = bundles.get(bundle_name)
            site.set_bundle(new_bundle)
            return new_bundle
예제 #18
0
 def tmpl_text(name):
     foo = bundles.get("CHM-Foo")
     tmpl = foo.queryUtility(ITemplate, name=name)
     if tmpl is None:
         return None
     else:
         tmpl._cook_check()
         return tmpl._text
예제 #19
0
 def tmpl_text(name):
     foo = bundles.get("CHM-Foo")
     tmpl = foo.queryUtility(ITemplate, name=name)
     if tmpl is None:
         return None
     else:
         tmpl._cook_check()
         return tmpl._text
예제 #20
0
    def setUp(self):
        super(DestinetTestCase, self).setUp()
        # EW setup
        portal_id = self.portal.getId()
        self.app._delObject(portal_id)
        portal_id = 'demo-design'
        manage_addEnviroWindowsSite(self.app, portal_id)
        self.portal = self.app[portal_id]
        # Destinet setup
        addNyFolder(self.portal, 'topics')
        addNyFolder(self.portal.topics, 'atopic')
        addNyFolder(self.portal, 'who-who')
        addNyFolder(self.portal['who-who'], 'atarget_group')
        addNyFolder(self.portal['who-who'], 'destinet-users')
        addNyFolder(self.portal, 'resources')
        addNyFolder(self.portal, 'market-place')
        addNyFolder(self.portal, 'News')
        addNyFolder(self.portal, 'events')
        addNyFolder(self.portal, 'countries')
        addNyFolder(self.portal.countries, 'georgia', title='Georgia')
        addNyFolder(self.portal.countries, 'southgeorgia', title='South Georgia')
        schema = self.portal.portal_schemas['NyURL']
        schema.addWidget('topics', widget_type='SelectMultiple', data_type='list')
        schema.addWidget('target-groups', widget_type='SelectMultiple', data_type='list')
        self.portal.getSchemaTool().addSchema('registration', 'registration')
        schema = self.portal.portal_schemas['registration']
        schema.addWidget('groups', widget_type='SelectMultiple', data_type='list')

        nycontactschema = self.portal.portal_schemas['NyContact']
        nycontactschema.addWidget('category-organization', widget_type="GeoType", data_type='str', required=True)
        nycontactschema.addWidget('category-marketplace', widget_type="GeoType", data_type='str', required=False)
        nycontactschema.addWidget('category-supporting-solutions', widget_type="GeoType", data_type='str', required=False)

        #import pdb; pdb.set_trace()

        manage_addDestinetPublisher(self.portal)
        cat = self.portal.getCatalogTool()
        cat.addIndex('pointer', 'FieldIndex')
        # set bundle
        naaya_b = bundles.get("Naaya")
        ew_b = bundles.get("EW")
        bundle = bundles.get("DESTINET-demo-design")
        ew_b.set_parent(naaya_b)
        bundle.set_parent(ew_b)
        self.portal.set_bundle(bundle)
예제 #21
0
 def test_set_bundle(self):
     self.bundle_names.append('bundle-for-portal-test')
     bundle = bundles.get('bundle-for-portal-test')
     portal = NySite('portal')
     portal.set_bundle(bundle)
     ob = MyClass()
     bundle.registerUtility(ob)
     portal_site_manager = portal.getSiteManager()
     self.assertTrue(portal_site_manager.getUtility(ITestUtil) is ob)
예제 #22
0
 def test_set_bundle(self):
     self.bundle_names.append('bundle-for-portal-test')
     bundle = bundles.get('bundle-for-portal-test')
     portal = NySite('portal')
     portal.set_bundle(bundle)
     ob = MyClass()
     bundle.registerUtility(ob)
     portal_site_manager = portal.getSiteManager()
     self.assertTrue(portal_site_manager.getUtility(ITestUtil) is ob)
예제 #23
0
 def setUp(self):
     from Products.Naaya.interfaces import INySite
     from Products.Naaya.NySite import NySite
     from naaya.core.interfaces import IFilesystemBundleFactory
     from naaya.core.fsbundles import register_bundle_factory
     self.bundle_names = []
     self.tmp = tempfile.mkdtemp()
     register_bundle_factory(self.tmp, 'FooSites-', 'Foo')
     self.site = NySite('bar')
     self.site.set_bundle(bundles.get('Foo'))
예제 #24
0
 def setUp(self):
     from Products.Naaya.interfaces import INySite
     from Products.Naaya.NySite import NySite
     from naaya.core.interfaces import IFilesystemBundleFactory
     from naaya.core.fsbundles import register_bundle_factory
     self.bundle_names = []
     self.tmp = tempfile.mkdtemp()
     register_bundle_factory(self.tmp, 'FooSites-', 'Foo')
     self.site = NySite('bar')
     self.site.set_bundle(bundles.get('Foo'))
예제 #25
0
    def __of__(self, parent):
        """
        When this NaayaPageTemplateFile is placed in an acquisition context,
        we do our magic: look up the correct (perhaps customized) template
        and return that instead of ourselves.
        """

        try:
            site = parent.getSite()
        except AttributeError, e:
            sm = bundles.get(self._bundle_name)
예제 #26
0
    def __of__(self, parent):
        """
        When this NaayaPageTemplateFile is placed in an acquisition context,
        we do our magic: look up the correct (perhaps customized) template
        and return that instead of ourselves.
        """

        try:
            site = parent.getSite()
        except AttributeError, e:
            sm = bundles.get(self._bundle_name)
예제 #27
0
    def test_modified_utilities(self):
        """ Check that templates registered in component registries show up """
        lsm = self.portal.getSiteManager()
        lsm.registerUtility(MyClass, ITestUtil, 'test_utility')
        transaction.commit()

        naaya_bundle = bundles.get("Naaya")
        naaya_bundle.registerUtility(MyClass, ITestUtil, 'test_utility')
        self.browser.go(self.portal.absolute_url() +
                '/inspector_view?interface=ITestUtil')
        self.assertEqual(self.browser.get_html().count('title="provides"'), 2)
예제 #28
0
    def test_modified_utilities(self):
        """ Check that templates registered in component registries show up """
        lsm = self.portal.getSiteManager()
        lsm.registerUtility(MyClass, ITestUtil, 'test_utility')
        transaction.commit()

        naaya_bundle = bundles.get("Naaya")
        naaya_bundle.registerUtility(MyClass, ITestUtil, 'test_utility')
        self.browser.go(self.portal.absolute_url() +
                '/inspector_view?interface=ITestUtil')
        self.assertEqual(self.browser.get_html().count('title="provides"'), 2)
예제 #29
0
    def test_load_templates(self):
        self.bundle_names.append("CHM-Foo")
        self._write_template('bar', "Hello Bar")

        from naaya.core import fsbundles
        fsbundles.load_filesystem_bundle(self.bundle_path, "CHM-Foo")
        foo = bundles.get("CHM-Foo")
        bar = foo.queryUtility(ITemplate, name='bar')

        self.assertTrue(bar is not None, "Template `bar` not found")
        bar._cook_check()
        self.assertEqual(bar._text, "Hello Bar")
예제 #30
0
    def test_load_templates(self):
        self.bundle_names.append("CHM-Foo")
        self._write_template('bar', "Hello Bar")

        from naaya.core import fsbundles
        fsbundles.load_filesystem_bundle(self.bundle_path, "CHM-Foo")
        foo = bundles.get("CHM-Foo")
        bar = foo.queryUtility(ITemplate, name='bar')

        self.assertTrue(bar is not None, "Template `bar` not found")
        bar._cook_check()
        self.assertEqual(bar._text, "Hello Bar")
예제 #31
0
    def test_inheritance(self):
        self.bundle_names.extend(['test_bundle_1', 'test_bundle_2'])
        my_bundle_1 = bundles.get('test_bundle_1')
        my_bundle_2 = bundles.get('test_bundle_2')
        my_bundle_2.set_parent(my_bundle_1)

        # inherit from global registry
        gsm = getGlobalSiteManager()
        ob_0 = MyClass()
        gsm.registerUtility(ob_0)
        self.assertTrue(my_bundle_2.getUtility(ITestUtil) is ob_0)
        gsm.unregisterUtility(ob_0)

        # inherit from parent
        ob_1 = MyClass()
        my_bundle_1.registerUtility(ob_1)
        self.assertTrue(my_bundle_2.getUtility(ITestUtil) is ob_1)

        # override
        ob_2 = MyClass()
        my_bundle_2.registerUtility(ob_2)
        self.assertTrue(my_bundle_2.getUtility(ITestUtil) is ob_2)
예제 #32
0
    def test_inheritance(self):
        self.bundle_names.extend(['test_bundle_1', 'test_bundle_2'])
        my_bundle_1 = bundles.get('test_bundle_1')
        my_bundle_2 = bundles.get('test_bundle_2')
        my_bundle_2.set_parent(my_bundle_1)

        # inherit from global registry
        gsm = getGlobalSiteManager()
        ob_0 = MyClass()
        gsm.registerUtility(ob_0)
        self.assertTrue(my_bundle_2.getUtility(ITestUtil) is ob_0)
        gsm.unregisterUtility(ob_0)

        # inherit from parent
        ob_1 = MyClass()
        my_bundle_1.registerUtility(ob_1)
        self.assertTrue(my_bundle_2.getUtility(ITestUtil) is ob_1)

        # override
        ob_2 = MyClass()
        my_bundle_2.registerUtility(ob_2)
        self.assertTrue(my_bundle_2.getUtility(ITestUtil) is ob_2)
예제 #33
0
        def create_bundle():
            """ Create a writable bundle on demand. """
            site_path = site.getPhysicalPath()
            if site_path[0] == '': # remove first empty path
                site_path = site_path[1:]
            bundle_name = name_prefix + '-'.join(site_path)

            site_parent = get_site_parent(site)
            parent_bundle = bundles.get(parent_name)
            if site_parent is not parent_bundle:
                raise ValueError("Site has wrong parent, %r != %r" %
                                 (site_parent, parent_bundle))
            bundle_path = os.path.join(bundles_dir, bundle_name + ".bundle")
            log.info("Creating bundle %r at %r", bundle_name, bundle_path)
            try:
                os.makedirs(bundle_path)
            except OSError, e:
                raise ValueError("Filesystem bundle %r already exists (%s)" %
                                 (bundle_name, e))
예제 #34
0
def manage_addCHMSite(self, id='', title='', lang=None, google_api_keys=None,
                      load_glossaries=[], bundle_name='CHM', REQUEST=None):
    """ """
    if REQUEST is not None:
        # we'll need the SESSION later on; grab it early so we don't
        # get a ConflictError.
        REQUEST.SESSION
    ut = utils()
    id = ut.utCleanupId(id)
    if not id: id = PREFIX_SITE + ut.utGenRandomId(6)
    chm_site = CHMSite(id, title=title, lang=lang)
    chm_site.set_bundle(bundles.get(bundle_name))
    self._setObject(id, chm_site)
    chm_site = self._getOb(id)
    chm_site.loadDefaultData(load_glossaries, _get_skel_handler(bundle_name))

    if google_api_keys:
        engine = chm_site.getGeoMapTool()['engine_google']
        engine.api_keys = google_api_keys

    if REQUEST is not None:
        return self.manage_main(self, REQUEST, update_menu=1)
예제 #35
0
 def test_unique_name(self):
     self.bundle_names.append('some_random_test_bundle')
     my_bundle_1 = bundles.get('some_random_test_bundle')
     my_bundle_2 = bundles.get('some_random_test_bundle')
     self.assertTrue(my_bundle_1 is my_bundle_2)
예제 #36
0
 def test_register_utility(self):
     self.bundle_names.append('some_random_test_bundle')
     my_bundle = bundles.get('some_random_test_bundle')
     ob = MyClass()
     my_bundle.registerUtility(ob)
     self.assertTrue(my_bundle.getUtility(ITestUtil) is ob)
예제 #37
0
""" Patch CHMSite
"""
from os.path import join

from naaya.component import bundles

from Products.CHM2.CHMSite import CHMSite
from constants import CHM2BE_PRODUCT_PATH

def wrap_loadDefaultData(method):
    def loadDefaultData(self, *args, **kwargs):
        method(self, *args, **kwargs)
        self.loadSkeleton(join(CHM2BE_PRODUCT_PATH))

        parent_bundle_name = self.get_bundle().__name__
        if parent_bundle_name == 'CHM3':
            self.set_bundle(chm3_be_bundle)
        else:
            self.set_bundle(chmbe_bundle)

    return loadDefaultData

CHMSite.product_paths.append(CHM2BE_PRODUCT_PATH)
CHMSite.loadDefaultData = wrap_loadDefaultData(CHMSite.loadDefaultData)

chmbe_bundle = bundles.get("CHMBE")
chmbe_bundle.set_parent(bundles.get("CHM"))

chm3_be_bundle = bundles.get("CHM3-BE")
chm3_be_bundle.set_parent(bundles.get("CHM3"))
예제 #38
0
 def test_wrong_site_bundle(self):
     from naaya.core.fsbundles import get_filesystem_bundle_factory
     self.site.set_bundle(bundles.get('Baz'))
     factory = get_filesystem_bundle_factory(self.site)
     self.assertTrue(factory is None)
예제 #39
0

def manage_addGroupwareSite(self, id='', title='', lang=None, REQUEST=None):
    """ """
    ut = utils()
    id = ut.utCleanupId(id)
    if not id:
        id = 'gw' + ut.utGenRandomId(6)
    self._setObject(id, GroupwareSite(id, title=title, lang=lang))
    ob = self._getOb(id)
    ob.loadDefaultData()
    if REQUEST is not None:
        return self.manage_main(self, REQUEST, update_menu=1)
    return ob

groupware_bundle = bundles.get("Groupware")
groupware_bundle.set_parent(bundles.get("Naaya"))
NETWORK_NAME = get_zope_env('NETWORK_NAME', 'Eionet')

ACTION_LOG_TYPES = {
    'role_request': 'IG role request',
    'role_request_review': 'IG role request review'
}


class GroupwareSite(NySite):
    """ """
    implements(IGWSite)
    meta_type = METATYPE_GROUPWARESITE
    # icon = 'misc_/GroupwareSite/site.gif'
예제 #40
0
def manage_addGroupwareSite(self, id='', title='', lang=None, REQUEST=None):
    """ """
    ut = utils()
    id = ut.utCleanupId(id)
    if not id:
        id = 'gw' + ut.utGenRandomId(6)
    self._setObject(id, GroupwareSite(id, title=title, lang=lang))
    ob = self._getOb(id)
    ob.loadDefaultData()
    if REQUEST is not None:
        return self.manage_main(self, REQUEST, update_menu=1)
    return ob


groupware_bundle = bundles.get("Groupware")
groupware_bundle.set_parent(bundles.get("Naaya"))
NETWORK_NAME = get_zope_env('NETWORK_NAME', 'Eionet')

ACTION_LOG_TYPES = {
    'role_request': 'IG role request',
    'role_request_review': 'IG role request review'
}


class GroupwareSite(NySite):
    """ """
    implements(IGWSite)
    meta_type = METATYPE_GROUPWARESITE
    # icon = 'misc_/GroupwareSite/site.gif'
예제 #41
0
 def test_pickle(self):
     self.bundle_names.append('some_random_test_bundle')
     my_bundle = bundles.get('some_random_test_bundle')
     jar = cPickle.dumps(my_bundle)
     self.assertTrue(cPickle.loads(jar) is my_bundle)
예제 #42
0
 def test_unique_name(self):
     self.bundle_names.append('some_random_test_bundle')
     my_bundle_1 = bundles.get('some_random_test_bundle')
     my_bundle_2 = bundles.get('some_random_test_bundle')
     self.assertTrue(my_bundle_1 is my_bundle_2)
예제 #43
0
    if not id: id = PREFIX_SITE + ut.utGenRandomId(6)
    chm_site = CHMSite(id, title=title, lang=lang)
    chm_site.set_bundle(bundles.get(bundle_name))
    self._setObject(id, chm_site)
    chm_site = self._getOb(id)
    chm_site.loadDefaultData(load_glossaries, _get_skel_handler(bundle_name))

    if google_api_keys:
        engine = chm_site.getGeoMapTool()['engine_google']
        engine.api_keys = google_api_keys

    if REQUEST is not None:
        return self.manage_main(self, REQUEST, update_menu=1)


chm_bundle = bundles.get("CHM")
chm_bundle.set_parent(bundles.get("Naaya"))
chm3_bundle = bundles.get("CHM3")
chm3_bundle.set_parent(bundles.get("Naaya"))


class CHMSite(NySite):
    """ """
    implements(ICHMSite)
    meta_type = METATYPE_CHMSITE
    icon = 'misc_/CHM2/Site.gif'

    manage_options = (NySite.manage_options)
    product_paths = NySite.product_paths + [CHM2_PRODUCT_PATH]

    security = ClassSecurityInfo()
예제 #44
0
 def test_wrong_site_bundle(self):
     from naaya.core.fsbundles import get_filesystem_bundle_factory
     self.site.set_bundle(bundles.get('Baz'))
     factory = get_filesystem_bundle_factory(self.site)
     self.assertTrue(factory is None)
예제 #45
0
 def set_bundle(self, bundle_name):
     self.context.getSite().set_bundle(bundles.get(bundle_name))
예제 #46
0
 def test_register_utility(self):
     self.bundle_names.append('some_random_test_bundle')
     my_bundle = bundles.get('some_random_test_bundle')
     ob = MyClass()
     my_bundle.registerUtility(ob)
     self.assertTrue(my_bundle.getUtility(ITestUtil) is ob)
from naaya.core.exceptions import i18n_exception

log = logging.getLogger(__name__)

manage_addEnviroWindowsSite_html = PageTemplateFile('zpt/site_manage_add', globals())
def manage_addEnviroWindowsSite(self, id='', title='', lang=None, REQUEST=None):
    """ """
    ut = utils()
    id = ut.utCleanupId(id)
    if not id: id = PREFIX_SITE + ut.utGenRandomId(6)
    self._setObject(id, EnviroWindowsSite(id, title=title, lang=lang))
    self._getOb(id).loadDefaultData()
    if REQUEST is not None:
        return self.manage_main(self, REQUEST, update_menu=1)

ew_bundle = bundles.get("EW")
ew_bundle.set_parent(bundles.get("Naaya"))

class EnviroWindowsSite(NySite):
    """ """
    implements(IEWSite)
    meta_type = METATYPE_ENVIROWINDOWSSITE
    icon = 'misc_/EnviroWindows/Site.gif'

    manage_options = (
        NySite.manage_options
    )
    product_paths = NySite.product_paths + [ENVIROWINDOWS_PRODUCT_PATH]

    security = ClassSecurityInfo()
    display_subobject_count = "on"
예제 #48
0
 def test_pickle(self):
     self.bundle_names.append('some_random_test_bundle')
     my_bundle = bundles.get('some_random_test_bundle')
     jar = cPickle.dumps(my_bundle)
     self.assertTrue(cPickle.loads(jar) is my_bundle)
예제 #49
0
from os.path import join

from naaya.component import bundles

from Products.CHM2.CHMSite import CHMSite
from constants import CHM2BE_PRODUCT_PATH


def wrap_loadDefaultData(method):
    def loadDefaultData(self, *args, **kwargs):
        method(self, *args, **kwargs)
        self.loadSkeleton(join(CHM2BE_PRODUCT_PATH))

        parent_bundle_name = self.get_bundle().__name__
        if parent_bundle_name == 'CHM3':
            self.set_bundle(chm3_be_bundle)
        else:
            self.set_bundle(chmbe_bundle)

    return loadDefaultData


CHMSite.product_paths.append(CHM2BE_PRODUCT_PATH)
CHMSite.loadDefaultData = wrap_loadDefaultData(CHMSite.loadDefaultData)

chmbe_bundle = bundles.get("CHMBE")
chmbe_bundle.set_parent(bundles.get("CHM"))

chm3_be_bundle = bundles.get("CHM3-BE")
chm3_be_bundle.set_parent(bundles.get("CHM3"))
예제 #50
0
    if not id:
        id = PREFIX_SITE + ut.utGenRandomId(6)
    chm_site = CHMSite(id, title=title, lang=lang)
    chm_site.set_bundle(bundles.get(bundle_name))
    self._setObject(id, chm_site)
    chm_site = self._getOb(id)
    chm_site.loadDefaultData(load_glossaries, _get_skel_handler(bundle_name))

    if google_api_keys:
        engine = chm_site.getGeoMapTool()['engine_google']
        engine.api_keys = google_api_keys

    if REQUEST is not None:
        return self.manage_main(self, REQUEST, update_menu=1)

chm_bundle = bundles.get("CHM")
chm_bundle.set_parent(bundles.get("Naaya"))
chm3_bundle = bundles.get("CHM3")
chm3_bundle.set_parent(bundles.get("Naaya"))


class CHMSite(NySite):
    """ """
    implements(ICHMSite)
    meta_type = METATYPE_CHMSITE
    icon = 'misc_/CHM2/Site.gif'

    manage_options = (
        NySite.manage_options
    )
    product_paths = NySite.product_paths + [CHM2_PRODUCT_PATH]
예제 #51
0
 def set_bundle(self, bundle_name):
     self.context.getSite().set_bundle(bundles.get(bundle_name))