def collector_vocabulary(context):
    terms = []
    # get local floor first
    site = get_site()
    # do not process local configuration if the current site is PloneSite
    if not IPloneSiteRoot.providedBy(site):
        utility = component.queryUtility(ILocalNewsletterLookup, name=get_name_for_site(site))
        if utility is not None:
            local_lookup_utility = utility.get("newsletter_lookup", None)
            if local_lookup_utility:
                for collector in local_lookup_utility.local_collectors():
                    terms.append(
                        zope.schema.vocabulary.SimpleTerm(
                            value=collector, token="/".join(collector.getPhysicalPath()), title=collector.title
                        )
                    )

    # get global collectors (original vocabulary code)
    root = component.getUtility(IPloneSiteRoot)
    collectors = root["portal_newsletters"]["collectors"].objectValues()
    for collector in collectors:
        terms.append(
            zope.schema.vocabulary.SimpleTerm(
                value=collector, token="/".join(collector.getPhysicalPath()), title=collector.title
            )
        )
    return zope.schema.vocabulary.SimpleVocabulary(terms)
def disable_party(context):
    if ISite.providedBy(context):
        sm = context.getSiteManager()
        name = get_name_for_site(context)
        lookup = context.get("newsletter_lookup")
        if lookup is not None:
            sm.unregisterUtility(name=name, provided=ILocalNewsletterLookup)
def disable_party(context):
    if ISite.providedBy(context):
        sm = context.getSiteManager()
        name = get_name_for_site(context)
        lookup = context.get("newsletter_lookup")
        if lookup is not None:
            sm.unregisterUtility(name=name, provided=ILocalNewsletterLookup)
Example #4
0
def collector_vocabulary(context):
    terms = []
    # get local floor first
    site = get_site()
    # do not process local configuration if the current site is PloneSite
    if not IPloneSiteRoot.providedBy(site):
        utility = component.queryUtility(ILocalNewsletterLookup, name=get_name_for_site(site))
        if utility is not None:
            local_lookup_utility=utility.get('newsletter_lookup',None)
            if local_lookup_utility:
                for collector in local_lookup_utility.local_collectors():
                    terms.append(
                        zope.schema.vocabulary.SimpleTerm(
                            value=collector,
                            token='/'.join(collector.getPhysicalPath()),
                            title=collector.title))
            
    # get global collectors (original vocabulary code)
    root = component.getUtility(IPloneSiteRoot)
    collectors = root['portal_newsletters']['collectors'].objectValues()
    for collector in collectors:
        terms.append(
            zope.schema.vocabulary.SimpleTerm(
                value=collector,
                token='/'.join(collector.getPhysicalPath()),
                title=collector.title))
    return zope.schema.vocabulary.SimpleVocabulary(terms)
def enable_party(context):
    """ Make this container a local site and add all
        the needed tools, if they're not there yet.
    """
    if not ISite.providedBy(context):
        make_objectmanager_site(context)
    sm = context.getSiteManager()
    name = get_name_for_site(context)

    add_tools(context)

    lookup = context.get("newsletter_lookup")

    interface.directlyProvides(lookup, ILocalNewsletterLookup)
    sm.registerUtility(lookup, name=name, provided=ILocalNewsletterLookup)
def enable_party(context):
    """ Make this container a local site and add all
        the needed tools, if they're not there yet.
    """
    if not ISite.providedBy(context):
        make_objectmanager_site(context)
    sm = context.getSiteManager()
    name = get_name_for_site(context)

    add_tools(context)

    lookup = context.get("newsletter_lookup")

    interface.directlyProvides(lookup, ILocalNewsletterLookup)
    sm.registerUtility(lookup, name=name, provided=ILocalNewsletterLookup)
Example #7
0
 def __call__(self):
     #site = get_site()
     site = getSite()
     name = get_name_for_site(site)
     lookup_utility = None
     try:
         lookup_utility = component.queryUtility(ILocalNewsletterLookup, name=name)
     except KeyError:
         logger.exception('Error looking up utility: %s ' % name)
     except AttributeError:
         logger.exception('Error looking up utility: %s ' % name)
     if lookup_utility:
         local_lookup_utility = lookup_utility.get('newsletter_lookup', None)
         if local_lookup_utility:
             for channel in local_lookup_utility.local_channels():
                 channel = fix_request(channel, 0)
                 yield channel
Example #8
0
 def __call__(self):
     site = getSite()
     name = get_name_for_site(site)
     lookup_utility = None
     try:
         lookup_utility = component.queryUtility(ILocalNewsletterLookup,
                                                 name=name)
     except KeyError:
         logger.exception('Error looking up utility: %s ' % name)
     except AttributeError:
         logger.exception('Error looking up utility: %s ' % name)
     if lookup_utility:
         local_lookup_utility = lookup_utility.get('newsletter_lookup',
                                                   None)
         if local_lookup_utility:
             for channel in local_lookup_utility.local_channels():
                 channel = fix_request(channel, 0)
                 yield channel