class HomepageLinkedData(GenericLinkedData): """ ILinkedData implemention for homepages """ adapts(ILinkedDataHomepage) def get_jsonld_context(self): context = { surf.ns.SCHEMA['Image']: surf.ns.SCHEMA['ImageObject'], surf.ns.SCHEMA['productID']: surf.ns.SCHEMA['about'], } return context def modify(self, obj2surf): print("This is a homepage") pass class LinkedDataHomepageData(Persistent): adapts(ILinkedDataHomepage) implements(ILinkedDataHomepageData) KEY = 'LinkedDataHomepage' linked_data_annotation = factory(LinkedDataHomepageData, key=KEY)
history = context.workflow_history[wfname] history += ({ 'action': 'Archive', 'review_state': state, 'actor': actor, 'comments': comments, 'time': date, },) context.workflow_history[wfname] = history context.workflow_history._p_changed = True context.reindexObject() notify(ObjectModifiedEvent(context)) archive_annotation_storage = factory(ObjectArchivedAnnotationStorage, key="eea.workflow.archive") # helper functions def archive_object(context, **kwargs): """ Archive given context :param context: object :param kwargs: options that are passed to the archive method directly affecting it's results if they are passed """ storage = queryAdapter(context, IObjectArchivator) storage.archive(context, **kwargs) return context def unarchive_object(context): """ Unarchive given context
""" adapts(ILinkedDataHomepage) def get_jsonld_context(self): """ Get jsonld context """ context = { surf.ns.SCHEMA['Image']: surf.ns.SCHEMA['ImageObject'], surf.ns.SCHEMA['productID']: surf.ns.SCHEMA['about'], } return context def modify(self, obj2surf): """ Modify """ print "This is a homepage" class LinkedDataHomepageData(Persistent): """ LinkedDataHomepageData """ adapts(ILinkedDataHomepage) implements(ILinkedDataHomepageData) KEY = 'LinkedDataHomepage' linked_data_annotation = factory(LinkedDataHomepageData, key=KEY)
history = context.workflow_history[wfname] history += ({ 'action': 'Archive', 'review_state': state, 'actor': actor, 'comments': comments, 'time': date, }, ) context.workflow_history[wfname] = history context.workflow_history._p_changed = True context.reindexObject() notify(Purge(context)) archive_annotation_storage = factory(ObjectArchivedAnnotationStorage, key="eea.workflow.archive") # helper functions def archive_object(context, **kwargs): """ Archive given context :param context: object :param kwargs: options that are passed to the archive method directly affecting it's results if they are passed """ storage = queryAdapter(context, IObjectArchivator) storage.archive(context, **kwargs) return context def archive_obj_and_children(context, **kwargs):
logger = logging.getLogger('zojax.widget.captcha') class IRecaptchaInfo(Interface): error = schema.TextLine() verified = schema.Bool() class RecaptchaInfoAnnotation(object): implements(IRecaptchaInfo) adapts(IBrowserRequest) def __init__(self): self.error = None self.verified = False RecaptchaInfo = factory(RecaptchaInfoAnnotation) class RecaptchaResponse(object): def __init__(self, is_valid, error_code=None): self.is_valid = is_valid self.error_code = error_code def displayhtml(public_key): includeInplaceSource( "<script src='https://www.google.com/recaptcha/api.js'></script>") return '<div class="g-recaptcha" data-sitekey="%(PublicKey)s"></div>' % { 'PublicKey': public_key, }
from zope.annotation.factory import factory from zope.component import adapter from zope.interface import implementer from BTrees.OOBTree import OOBTree from Products.CMFPlone.interfaces.siteroot import IPloneSiteRoot from . import ANNOTATION_KEY from .interfaces import ITranslationsStorage @implementer(ITranslationsStorage) @adapter(IPloneSiteRoot) class TranslationsStorage(OOBTree): pass annotfactory = factory(TranslationsStorage, key=ANNOTATION_KEY)
class DescriptorsView(BaseComplianceView): name = 'comp-start' @property def descriptors(self): return GES_DESCRIPTORS @implementer(IRecommendationStorage) @adapter(IPloneSiteRoot) class RecommendationStorage(OOBTree): pass annotfactory_rec = factory(RecommendationStorage, key=ANNOTATION_KEY) class Recommendation(Persistent): def __init__(self, id_rec, code, topic, text, ms_region, descriptors): self._id_recommendation = id_rec self.code = code self.topic = topic self.text = text if not hasattr(ms_region, '__iter__'): ms_region = [ms_region] self.ms_region = ms_region if not hasattr(descriptors, '__iter__'):