示例#1
0
    title = None

    id = None

    name = None

    def __init__(self, name='', title=''):
        self.name = unicode(name)
        self.title = unicode(title)


class LeadFormFactory(object):
    interface.implements(ILeadFormFactory)

    title = None

    name = None

    def __call__(self):
        return LeadForm(self.name, self.title)


registerFactoryAdapter(ILeadForm, LeadForm)


class EmbedHubSpotForm(PersistentItem):
    interface.implements(IEmbedHubSpotForm)

    body = RichTextProperty(IEmbedHubSpotForm['body'])
    embed = FieldProperty(IEmbedHubSpotForm['embed'])
示例#2
0
"""

$Id$
"""
from zojax.blogger.interfaces import IBlogPostPage

from zope import interface
from zope.schema.fieldproperty import FieldProperty

from z3c.form.object import registerFactoryAdapter

from zojax.richtext.field import RichTextProperty


class BlogPostPage(object):
    interface.implements(IBlogPostPage)

    title = None

    text = RichTextProperty(IBlogPostPage['text'])

    position = FieldProperty(IBlogPostPage['position'])



registerFactoryAdapter(IBlogPostPage, BlogPostPage)

# registerFactoryAdapter(IImageRotatorSimpleImage, ImageRotatorSimpleImage)

# registerFactoryAdapter(IImageRotatorButton, ImageRotatorButton)
示例#3
0
from bit.plone.graphic.browser.interfaces\
    import IGraphicsForm, IGraphicAssociation


class GraphicAssociation(object):
    implements(IGraphicAssociation)
    title = u'association'

    def __init__(self):
        pass

    def update(self, name, assoc):
        self.name = name
        self.association = assoc
        return self
registerFactoryAdapter(IGraphicAssociation, GraphicAssociation)


class GraphicsFormAdapter(object):

    def __init__(self, context, *largs, **kwargs):
        self.context = context
        graphical = IGraphical(self.context, None)
        self.graphics = '\n'.join(graphical.get_raw_list())
        self.custom_graphic = ICustomGraphic(self.context).get_image()
        self.graphic_associations = [
            GraphicAssociation().update(unicode(x), unicode(y or ''))
            for x, y in graphical.get_graphics().items()]


class GraphicsForm(form.EditForm):
示例#4
0
class IUnknown(interface.Interface):
    data_1 = schema.TextLine(title=u"Some text", default=u"Foo bar")
    data_2 = schema.TextLine(title=u"Other text", default=u"Baz qux")
    data_3 = schema.Tuple(title=u"Subtuple")


class Unknown(object):
    interface.implements(IUnknown)
    
    def __init__(self, data_1="", data_2="", data_3=[]):
        self.data_1 = u'a'
        self.data_2 = u'b'
        self.data_3 = ('a', 'b')

registerFactoryAdapter(IUnknown, Unknown)


#class UnknownFieldJSONAdapter(JSONifyBase):
#    
#    def data(self, record):
#        return {'data_1': record.data_1,
#                'data_2': record.data_2}

class ITestBase(interface.Interface):
    simple_text = schema.TextLine(title=u"Simple Text", default=u"Lorem Ipsum")


class ITest(ITestBase):
    
    long_text = schema.Text(title=u"Long Text", default=u"Lorem Ipsum")
from zope import schema, interface
import unittest
import zope.testing


class ITestObjectA(model.Schema):
    fish = schema.TextLine(
        title=u'Fish',
        default=u"",
        required=False)


@interface.implementer(ITestObjectA)
class TestObjectA(object):
    fish = schema.fieldproperty.FieldProperty(ITestObjectA['fish'])
registerFactoryAdapter(ITestObjectA, TestObjectA)


class ITestObjectB(model.Schema):
    title = schema.TextLine(
        title=u'Title',
        default=u"",
        required=False)
    cowtent = RichText(
        title=u"Text",
        default_mime_type='text/html',
        output_mime_type='text/html',
        allowed_mime_types=('text/html', 'scroll/dead-sea'),
        default=u"",
        required=False)
示例#6
0
    dk_alt = schema.TextLine(
        title=_("Danish Alt"),
        required=True
    )

    uk_alt = schema.TextLine(
        title=_("English Alt"),
        required=True
    )


class SocialShareItem(object):
    implements(ISocialShareItem)

registerFactoryAdapter(ISocialShareItem, SocialShareItem)

class ISocialShareSettings(Interface):
    """ Settings for social share module"""

    social_share_items = schema.Tuple(
        title=_(u'Settings'), 
        value_type=PersistentObject(ISocialShareItem, title=u"Social share item"),
    )
    
    form.widget(style=RadioFieldWidget)
    style = schema.Choice(
        title=_("Style"),
        vocabulary=SimpleVocabulary([SimpleVocabulary.createTerm(1, '1', _(u'List')), 
                                     SimpleVocabulary.createTerm(2, '2', _(u'DropDown'))]),
        default=1
class AjaxsearchSettingsEditForm(controlpanel.RegistryEditForm):
    """
    edit form for settings
    """
    schema = IAjaxsearchSettings
    label = u"Ajaxsearch settings"
    description = u""""""

    def updateFields(self):
        super(AjaxsearchSettingsEditForm, self).updateFields()

    def updateWidgets(self):
        super(AjaxsearchSettingsEditForm, self).updateWidgets()


class AjaxsearchSettingsControlPanel(controlpanel.ControlPanelFormWrapper):
    """
    control panel for settings
    """
    form = AjaxsearchSettingsEditForm


class AjaxsearchGroup(object):
    """
    group of config
    """
    zope.interface.implements(IAjaxsearchGroup)

registerFactoryAdapter(IAjaxsearchGroup, AjaxsearchGroup)
class IOptOutSettings(Interface):
    """Settings for the Optout"""

    optout_configuration = schema.Tuple(
        title=_(u'Opt-out configurations'),
        description=_(
            'help_optout_configuration',
            default=u'When the user accepted the general cookie policy he can still accept/decline '  # noqa
            u'a single kind of cookie(s) from a 3rd part application.\n'  # noqa
            u'From this panel you can configure opt-out cookies for those applications.\n'  # noqa
            u'PLEASE NOTE: this product will only handle and generate cookies, is duty of '  # noqa
            u'others products to use those cookies in the correct manner.',
        ),  # noqa
        value_type=OptOutEntryPersistentObject(
            IOptOutEntry, title=_(u'Opt-out configuration')
        ),
        required=False,
        default=(),
        missing_value=(),
    )


class ICookieConsentSettings(ICookieBannerSettings, IOptOutSettings):
    """Settings used in the control panel for cookiecosent: unified panel
    """


registerFactoryAdapter(ICookieBannerEntry, CookieBannerEntry)
registerFactoryAdapter(IOptOutEntry, OptOutEntry)
registerFactoryAdapter(IOptOutEntrySubitem, OptOutEntrySubitem)
from plone.supermodel import model

from transmogrify.dexterity.interfaces import ISerializer, IDeserializer


class ITestObjectA(model.Schema):
    fish = schema.TextLine(
        title=u'Fish',
        default=u"",
        required=False)


@interface.implementer(ITestObjectA)
class TestObjectA(object):
    fish = schema.fieldproperty.FieldProperty(ITestObjectA['fish'])
registerFactoryAdapter(ITestObjectA, TestObjectA)


class ITestObjectB(model.Schema):
    title = schema.TextLine(
        title=u'Title',
        default=u"",
        required=False)
    cowtent = RichText(
        title=u"Text",
        default_mime_type='text/html',
        output_mime_type='text/html',
        allowed_mime_types=('text/html', 'scroll/dead-sea'),
        default=u"",
        required=False)
示例#10
0
class IUnknown(interface.Interface):
    data_1 = schema.TextLine(title=u"Some text", default=u"Foo bar")
    data_2 = schema.TextLine(title=u"Other text", default=u"Baz qux")
    data_3 = schema.Tuple(title=u"Subtuple")


class Unknown(object):
    interface.implements(IUnknown)

    def __init__(self, data_1="", data_2="", data_3=[]):
        self.data_1 = u'a'
        self.data_2 = u'b'
        self.data_3 = ('a', 'b')


registerFactoryAdapter(IUnknown, Unknown)

#class UnknownFieldJSONAdapter(JSONifyBase):
#
#    def data(self, record):
#        return {'data_1': record.data_1,
#                'data_2': record.data_2}


class ITestBase(interface.Interface):
    simple_text = schema.TextLine(title=u"Simple Text", default=u"Lorem Ipsum")


class ITest(ITestBase):

    long_text = schema.Text(title=u"Long Text", default=u"Lorem Ipsum")
示例#11
0
    url = None


class ImageRotatorSimpleImage(object):
    interface.implements(IImageRotatorSimpleImage)

    title = None

    url = None

    image = FileFieldProperty(IImageRotatorItem['image'])

    position = FieldProperty(IImageRotatorItem['position'])

    text = RichTextProperty(IImageRotatorSimpleImage['text'])


class ImageRotatorButton(ImageRotatorItem):
    interface.implements(IImageRotatorButton)

    image = FileFieldProperty(IImageRotatorButton['image'])

    url = None


registerFactoryAdapter(IImageRotatorImage, ImageRotatorImage)

registerFactoryAdapter(IImageRotatorSimpleImage, ImageRotatorSimpleImage)

registerFactoryAdapter(IImageRotatorButton, ImageRotatorButton)
        old = sorted(old, key=lambda x: x.position)
        self.__dict__['tabs'] = old

    @property
    def text(self):
        return ''.join([getattr(tab.text, 'cooked', '') for tab in self.tabs])


class PageTab(object):
    interface.implements(IPageTab)

    title = None
    text = RichTextProperty(IPageTab['text'])
    position = FieldProperty(IPageTab['position'])

registerFactoryAdapter(IPageTab, PageTab)


class AdvancedPageView(object):
    """
    Advanced post view
    """
    def __init__(self, *args, **kw):
        include('advanced-page')
        super(AdvancedPageView, self).__init__(*args, **kw)


class AdvancedPageEditForm(EditContentWizard):
    interface.implements(ISaveable, IEditContentWizard)

    def __init__(self, *args, **kw):
示例#13
0
    user_id = FieldProperty(IResource['user_id'])
    active = FieldProperty(IResource['active'])
    compass_effort = FieldProperty(IResource['compass_effort'])

    __name__ = None
    __parent__ = None

    def getId(self):
        return self.__name__ or ''

    def __repr__(self):
        return '<%s (%s as %s)>' % (self.__class__.__name__, self.user_id,
                                    self.role)


registerFactoryAdapter(IResource, Resource)


class Environment(SimpleItem):

    implements(IEnvironment)

    name = FieldProperty(IEnvironment['name'])
    env_type = FieldProperty(IEnvironment['env_type'])
    url = FieldProperty(IEnvironment['url'])

    __name__ = None
    __parent__ = None

    def getId(self):
        return self.__name__ or ''
示例#14
0
@implementer(interfaces.IHazard)
class Hazard(Base):
    grok.title("Hazard")

    portal_type = "hazard"
    __tablename__ = 'hazards'

    id = Column('id', String(50), primary_key=True)
    type = Column('name', String(50))
    timespan = Column('category', String(50))
    product_id = Column('product_id', Integer, ForeignKey('products.id'))
    product = relation("Product", backref="hazards")

    def reindexObject(self, *args, **kwargs):
        pass


class HazardFTI(ContentFTI):
    grok.name('hazard')
    __model__ = Hazard
    schema = interfaces.IHazard
    klass = "nva.hhs.content.Hazard"


class HazardAddForm(AddForm):
    grok.name('hazard')


registerFactoryAdapter(interfaces.IHazard, Hazard)
示例#15
0
    types_settings = schema.Tuple(
        title=_(u'Settings for other content types and fields'),
        description=_(
            'help_types_settings',
            default=u"Use this section to provide size overrides of"
                    u" values above.\nProvide a content type/field ID,"
                    u" and the size limit."),
        value_type=PersistentObject(
            ITypesSettings,
            title=_(u"Content/field settings")),
        required=False,
        default=(),
        missing_value=(),
    )

    new_data_only = schema.Bool(
        title=_(u"Validate only new data"),
        description=_(
            "help_new_data_only",
            default=u"Keep selected to validate only new uploaded files and"
                    u" images.\nIf you unselect this and the size "
                    u"configurations above will be lowered, is possible that"
                    u" users that edit contents wont be able to save the form "
                    u"because the validator will check also data already"
                    u" saved."),
        default=True,
    )


registerFactoryAdapter(ITypesSettings, TypesSettings)
示例#16
0
                            constraint=validate_id)
    display_title = schema.ASCIILine(title=_(u"Title"), required=True,
                                     description=_(u"Display title as it will "
                                                   u"appear as field title."))
    description = schema.ASCIILine(title=_(u"Description"), required=False)
    vocabularies = schema.Choice(
            title=_(u"Type/Vocabulary"),
            description=_(u"Choose 'Free Text' for text field, 'Tags' for keywords field, or the rest of vocabulary to use to render facet items"),
            vocabulary="collective.facets.vocabularies.PortalVocabularies")


class IFacetSettings (Interface):
    facets = schema.Tuple(
            title=_(u'Additional Facet Fields'),
            description=(u"Names of additional keyword fields"),
            value_type=schema.Object(IFacetDefinition, title=_(u"Facet Definition")),
            required=False,
            default=(),
            missing_value=(),
    )


from z3c.form.object import registerFactoryAdapter


class FacetDefinition(object):
    implements(IFacetDefinition)


registerFactoryAdapter(IFacetDefinition, FacetDefinition)
# -*- coding: utf-8 -*-

from zope import schema
from zope.interface import Interface, implements
from z3c.form.object import registerFactoryAdapter
from plone.registry.field import PersistentField
from rer.groupware.room import roomMessageFactory as _


class IRoomGroupName(Interface):
    group_id = schema.ASCIILine(title=_(u"Group ID"), required=True)
    group_title = schema.TextLine(title=_(u"Group title"),
                                        required=False)


class RoomGroupName(object):
    implements(IRoomGroupName)


class PersistentObject(PersistentField, schema.Object):
    pass

registerFactoryAdapter(IRoomGroupName, RoomGroupName)

class IAdditionalAttrs(Interface):
    name = schema.TextLine(title=_(u"Attribute name"), required=True)
    value = schema.TextLine(title=_(u"Attribute value"), required=True)


class AdditionalAttrs(object):
    implements(IAdditionalAttrs)

    def __init__(self):
        self.name = None
        self.value = None


class IPersistentObject(Interface):
    pass

class PersistentObject(PersistentField, schema.Object):
    implements(IPersistentObject)


registerFactoryAdapter(IAdditionalAttrs, AdditionalAttrs)


class JSON(JSONifyBase):
    """Return the content of IAdditionalAttrs as a dict"""
    
    def data(self, record):
        return {'name': record.name, 'value': record.value}
    __name__ = ''
    __parent__ = None

    def getId(self):
        return self.__name__ or ''

    def to_dict(self):
        return {
            'title': self.title,
            'name': self.name,
            'url': self.url,
            'active': self.active,
        }

registerFactoryAdapter(ICalendar, Calendar)


class ICalendarView(Interface):

    calendars = schema.List(
        title=u'Calendars',
        description=u'',
        value_type=schema.Object(
            title=u"Calendar",
            schema=ICalendar
        ),
        required=True,
    )

示例#20
0
        missing_value="",
        required=False,
    )
    service_icon = schema.ASCIILine(
        title=_(u"Icon"),
        description=_(
            "velruse_backend_icon_help",
            default=u"An URL (can also be a relative path) to an icon to be displayed in "
            u"the login form. Best format is 64x64px.",
        ),
        missing_value="",
        required=False,
    )


class VelruseBackendConfig(object):
    implements(IVelruseBackendConfig)

    def __init__(self, service_name=u"", service_url="", service_icon=""):
        self.service_name = service_name
        self.service_url = service_url
        self.service_icon = service_icon


registerFactoryAdapter(IVelruseBackendConfig, VelruseBackendConfig)
allow_class(VelruseBackendConfig)


class PersistentObject(PersistentField, schema.Object):
    pass
示例#21
0
        default=u"",
        required=False)
    image_caption = schema.Text(
        title=_(u'Image caption'),
        description=_(u"Caption to go underneath images"),
        default=u"",
        required=False)


@interface.implementer(ISlideSection)
class SlideSection(object):
    title = schema.fieldproperty.FieldProperty(ISlideSection['title'])
    text = schema.fieldproperty.FieldProperty(ISlideSection['text'])
    image_code = schema.fieldproperty.FieldProperty(ISlideSection['image_code'])
    image_caption = schema.fieldproperty.FieldProperty(ISlideSection['image_caption'])
registerFactoryAdapter(ISlideSection, SlideSection)


class ISlide(model.Schema):
    id = schema.ASCIILine(
        title=_(u'Slide Id'),
        description=_(u"Change ID to become more readable. Slides appear in alphabetical order based on this value."),
        required=True)
    form.omitted('id')
    form.no_omit(IAddForm, 'id')
    title = schema.TextLine(
        title=_(u'Slide title'),
        description=_(u"The main title of the slide"),
        required=False)
    sections = schema.List(
        title=_(u'Slide sections'),
示例#22
0
        pass
    def set(self,id,contributor,school,hour,email=u''):
        self.id = id
        self.school = school
        self.contributor = contributor
        self.email = email
        if school in schools.keys():
            self.sector = schools[school][1]
        else:
            self.sector = u'non disponible'
        self.hour = hour
    def __repr__(self):
        return '<%s %r>' % (self.__class__.__name__, self.id)   
    
        
registerFactoryAdapter(ICouple, Couple)
class IAttribution(form.Schema):
    """
    Attribution horaire
    """
    title = schema.TextLine(
            title=_(u"Titre"),
            description=_(u"Défini le type d'attribution"),
            required=True,
        )
    

    hoursAttribution = schema.List(
            title=u"Attribution horaire par contributeur",
            value_type = schema.Object(
            schema = ICouple,required=False),
示例#23
0
    __name__ = ''
    __parent__ = None

    def getId(self):
        return self.__name__ or ''

    def to_dict(self):
        return {
            'title': self.title,
            'name': self.name,
            'url': self.url,
            'active': self.active,
        }


registerFactoryAdapter(ICalendar, Calendar)


class ICalendarView(Interface):

    calendars = schema.List(
        title=u'Calendars',
        description=u'',
        value_type=schema.Object(title=u"Calendar", schema=ICalendar),
        required=True,
    )


class CalendarView(ConfigurableBaseView):
    settings_schema = ICalendarView
from five import grok

from zope import schema

from z3c.form.object import registerFactoryAdapter

from plone.directives import dexterity, form
from plone.app.textfield import RichText

from upfront.assessmentitem import MessageFactory as _

class IAnswer(form.Schema):
    """
    Answer content type
    """

    answer = RichText(
            title=_(u"Answer")
        )

    iscorrect = schema.Bool(
            title=_(u"is correct?"),
            default=False,
        )        

class Answer(dexterity.Item):
    grok.implements(IAnswer)

registerFactoryAdapter(IAnswer, Answer)

示例#25
0
class SubObject(object):
    interface.implements(ISubObject)

    title = schema.fieldproperty.FieldProperty(ISubObject["title"])

    __name__ = ""
    __parent__ = None

    def getId(self):
        return self.__name__ or ""

    def __repr__(self):
        return "<SubObject title='%s'>" % self.title


registerFactoryAdapter(ISubObject, SubObject)


class IComplexForm(interface.Interface):

    object_field = schema.List(
        title=u"Object Field", required=False, value_type=schema.Object(title=u"object", schema=ISubObject)
    )


class ComplexForm(form.Form):
    fields = field.Fields(IComplexForm)
    label = u"Complex form"
    ignoreContext = True

示例#26
0
class IIndexesValueField(Interface):
    index_title = schema.ASCIILine(
        title=_("sitesearch_index_title", default=u"Index title"),
        description=_(
            "sitesearch_index_title_help",
            default=u"Insert a title for this search filter. You can provide translations for this title with a proper translation file for rer.sitesearch domain.",
        ),
        required=True,
    )
    index = schema.Choice(
        title=_(
            "sitesearch_allowable", default=u"Allowable indexes in catalog"
        ),
        description=_("sitesearch_allowable_help", default=u'Select an index.'),
        required=True,
        vocabulary=u"rer.sitesearch.vocabularies.IndexesVocabulary",
    )


class IndexesValueField(object):
    implements(IIndexesValueField)


class PersistentObject(PersistentField, schema.Object):
    pass


registerFactoryAdapter(ITabsValueField, TabsValueField)
registerFactoryAdapter(IIndexesValueField, IndexesValueField)
    types_settings = schema.Tuple(
        title=_(u'Settings for other content types and fields'),
        description=_(
            'help_types_settings',
            default=u"Use this section to provide size overrides of"
                    u" values above.\nProvide a content type/field ID,"
                    u" and the size limit."),
        value_type=PersistentObject(
            ITypesSettings,
            title=_(u"Content/field settings")),
        required=False,
        default=(),
        missing_value=(),
    )

    new_data_only = schema.Bool(
        title=_(u"Validate only new data"),
        description=_(
            "help_new_data_only",
            default=u"Keep selected to validate only new uploaded files and"
                    u" images.\nIf you unselect this and the size "
                    u"configurations above will be lowered, is possible that"
                    u" users that edit contents wont be able to save the form "
                    u"because the validator will check also data already"
                    u" saved."),
        default=True,
    )


registerFactoryAdapter(ITypesSettings, TypesSettings)
示例#28
0
                item.get('date', None),
                datefmt
            )
        except: # pragma: no cover
            # skip malformed date records
            return
        status = item.get('status', None)
        messages = item.get('messages', [])
        if not isinstance(messages, list):
            messages = [messages]
        messages = [unicode(a)
                    for a in messages]
        return cls(date=dt,
                status=status,
                messages=messages)
registerFactoryAdapter(ILog, Log)

class Cron(ConstrainedObject):
    implements(ICron)
    uid = FieldProperty(ICron['uid'])
    name = FieldProperty(ICron['name'])
    activated = FieldProperty(ICron['activated'])
    periodicity = FieldProperty(ICron['periodicity'])
    _logs = FieldProperty(ICron['logs'])
    environ = FieldProperty(ICron['environ'])
    logs_limit = FieldProperty(ICron['logs_limit'])
    """Limit logs to 25 to avoid large memory usage"""

    def __eq__(self, other):
        return self._eq__mixin(other)
示例#29
0
            u"This URL must be properly configured in Velruse to call the remote "
            u"service"),
        missing_value="",
        required=False)
    service_icon = schema.ASCIILine(
        title=_(u"Icon"),
        description=_(
            "velruse_backend_icon_help",
            default=
            u"An URL (can also be a relative path) to an icon to be displayed in "
            u"the login form. Best format is 64x64px."),
        missing_value="",
        required=False)


class VelruseBackendConfig(object):
    implements(IVelruseBackendConfig)

    def __init__(self, service_name=u'', service_url='', service_icon=""):
        self.service_name = service_name
        self.service_url = service_url
        self.service_icon = service_icon


registerFactoryAdapter(IVelruseBackendConfig, VelruseBackendConfig)
allow_class(VelruseBackendConfig)


class PersistentObject(PersistentField, schema.Object):
    pass
示例#30
0
from listwidget import ListFieldWidget
import attendee
from z3c.form.object import registerFactoryAdapter

class EventRegAddForm(AddForm):

    fields = Fields(IEventReg)

class EventRegGroupAddForm(AddForm):

    fields = Fields(IEventRegGroup)

class EventRegRegistrationAddForm(AddForm):

    fields = Fields(IEventRegRegistration).omit('title',  'surveys', 'invitations')

registerFactoryAdapter(IAttendee, attendee.Attendee)


class EventRegEditForm(EditForm):

    fields = Fields(IEventReg)

class EventRegGroupEditForm(EditForm):

    fields = Fields(IEventRegGroup)

class EventRegRegistrationEditForm(EditForm):

    fields = Fields(IEventRegRegistration).omit('title', 'surveys', 'invitations')
示例#31
0

class IAdditionalAttrs(Interface):
    name = schema.TextLine(title=_(u"Attribute name"), required=True)
    value = schema.TextLine(title=_(u"Attribute value"), required=True)


class AdditionalAttrs(object):
    implements(IAdditionalAttrs)

    def __init__(self):
        self.name = None
        self.value = None


class IPersistentObject(Interface):
    pass


class PersistentObject(PersistentField, schema.Object):
    implements(IPersistentObject)


registerFactoryAdapter(IAdditionalAttrs, AdditionalAttrs)


class JSON(JSONifyBase):
    """Return the content of IAdditionalAttrs as a dict"""
    def data(self, record):
        return {'name': record.name, 'value': record.value}
示例#32
0
                                                   u'applied to the context and all non-folderish children.\n'
                                                   u'This make sense only with folderish context.\n'
                                                   u'See "Advanced settings" section for defining what is a folder '
                                                   u'for your site.'),
                             required=True,
                             default=u'subtree',
                             vocabulary=u"collective.analyticspanel.vocabularies.apply_to_choices")
    position = schema.Choice(title=_(u"Include code in..."),
                             required=True,
                             default=u'footer',
                             vocabulary=u"collective.analyticspanel.vocabularies.positions")


class SitePathValuePair(object):
    implements(ISitePathValuePair)

    def __init__(self, path=None, path_snippet=None, apply_to=None, position='footer'):
        self.path = path
        self.path_snippet = path_snippet
        self.apply_to = apply_to
        self.position = position


class PersistentObject(PersistentField, schema.Object):
    pass


registerFactoryAdapter(IErrorCodeValuePair, ErrorCodeValuePair)
registerFactoryAdapter(ISitePathValuePair, SitePathValuePair)

示例#33
0
class ISitePathValuePair(Interface):
    path = schema.TextLine(title=_(u"Site path"), required=True)
    path_snippet = schema.SourceText(title=_(u"Code to include"),
                                     required=False)
    apply_to = schema.Choice(
        title=_(u"Apply rule to..."),
        description=_(
            'help_apply_to',
            default=u'Choose a policy for applying this rule.\n'
            u'When using "context and children" note that the rule will be '
            u'applied to the context and all non-folderish children.\n'
            u'This make sense only with folderish context.\n'
            u'See "Advanced settings" section for defining what is a folder '
            u'for your site.'),
        required=True,
        default=u'subtree',
        vocabulary=u"collective.analyticspanel.vocabularies.apply_to_choices")


class SitePathValuePair(object):
    implements(ISitePathValuePair)


class PersistentObject(PersistentField, schema.Object):
    pass


registerFactoryAdapter(IErrorCodeValuePair, ErrorCodeValuePair)
registerFactoryAdapter(ISitePathValuePair, SitePathValuePair)
class SubObject(object):
    interface.implements(ISubObject)

    title = schema.fieldproperty.FieldProperty(ISubObject['title'])

    __name__ = ''
    __parent__ = None

    def getId(self):
        return self.__name__ or ''

    def __repr__(self):
        return "<SubObject title='{0:s}'>".format(self.title)


registerFactoryAdapter(ISubObject, SubObject)


class IComplexForm(interface.Interface):

    object_field = schema.List(title=u"Object Field",
                               required=False,
                               value_type=schema.Object(title=u"object",
                                                        schema=ISubObject))


class ComplexForm(form.Form):
    fields = field.Fields(IComplexForm)
    label = u"Complex form"
    ignoreContext = True
示例#35
0
            default=u"",
            missing_value=u"",
            required=True,
    )

    types_matched = schema.Tuple(
            title=_(u'Select all native content types that match'),
            description=_('help_types_matched',
                          default=u"Select all primitive content types that will be queried when this new "
                                  u"general type will be selected."),
            required=True,
            default=(),
            missing_value=(),
            value_type=schema.Choice(vocabulary=u'plone.app.vocabularies.ReallyUserFriendlyTypes'),
    )


class RowTypesCriterionSettings(object):
    implements(IRowTypesCriterionSettings)
    
    def __init__(self, type_name=u'', types_matched=()):
        self.type_name = type_name
        self.types_matched = types_matched


class PersistentObject(PersistentField, schema.Object):
    pass


registerFactoryAdapter(IRowTypesCriterionSettings, RowTypesCriterionSettings)
        except AttributeError:
            request = None
        return SimpleVocabulary.fromItems((
                      (translate(_(u"Collapsed"), context=request), "collapsed"),
                      (translate(_(u"Expanded"), context=request), "expanded"),))


PortletStateVocabularyFactory = PortletStateVocabulary()


class ICollapserSettingsField(Interface):
    css_selector = schema.ASCIILine(title=_("collapser_cssselector_title", default=u"Portlet CSS Selector"),
                                 description=_("collapser_cssselector_help",
                                               default=u"Insert a css selector for the portlet where you want to activate the expand/collapse behaviour. For example 'dl.myPortletClass'."),
                                 required=True)
    default_state = schema.Choice(title=_("collapser_defaultstate_title", default=u"Portlet default state"),
                                  description=_("collapser_defaultstate_help",
                                               default=u"Select default state for this portlet."),
                                  required=False,
                                  vocabulary="portletcollapser-portlestates-vocabulary")


class CollapserSettingsField(object):
    implements(ICollapserSettingsField)


class PersistentObject(PersistentField, schema.Object):
    pass

registerFactoryAdapter(ICollapserSettingsField, CollapserSettingsField)
示例#37
0
                             description=_(u'Street Address.'),
                             required=False,
                             default=None)
    postal = schema.TextLine(title=_(u'Zip Code'),
                             description=_(u'Zip or Postal Code.'),
                             required=False,
                             default=None)


@implementer(IAddress)
class Address(object):
    street = FieldProperty(IAddress['street'])
    postal = FieldProperty(IAddress['postal'])


registerFactoryAdapter(IAddress, Address)


class IPerson(model.Schema):
    JobTitle = schema.TextLine(title=_(u'Job Title'))
    Department = schema.TextLine(title=_(u'Department'))

    fieldset('address',
             label=_(u'Address'),
             fields=['PhysicalAddress', 'PostalAddress'])
    PhysicalAddress = schema.Object(title=_(u'Physical Address'),
                                    schema=IAddress)
    PostalAddress = schema.Object(title=_(u'Postal Address'), schema=IAddress)


class IOrganization(model.Schema):
示例#38
0
    )

    grade = schema.Decimal(
        title=_(u"Grade"),
        description=_(u"The Grade you have become for this Course.")
    )


class Row(object):
    implements(IRow)

    def __init__(self):
        pass


registerFactoryAdapter(IRow, Row)


class ITable(Interface):

    row = schema.List(
        title=_(u"Row"),
        value_type=schema.Object(
            title=_(u"Row Object"),
            schema=IRow,
        ),
        required=False,
    )

    average = schema.Decimal(
        title=_(u"Average"),
示例#39
0
    language = schema.Choice(
        title=_(u"Language"),
        vocabulary="lmu.policy.base.AvailableLanguages",
    )
    text = schema.TextLine(title=_(u"Title"))


class TitleLanguagePair(object):
    implements(ITitleLanguagePair)

    def __init__(self, language='', text=''):
        self.language = language
        self.text = text


registerFactoryAdapter(ITitleLanguagePair, TitleLanguagePair)


class PersistentObject(PersistentField, schema.Object):
    pass


class ILMUSettings(Interface):
    """Custom settings"""

    breadcrumb_1_title = schema.List(
        title=_(u"Breadcrumb override level 1 - Title"),
        description=_(u""),
        value_type=PersistentObject(ITitleLanguagePair,
                                    title=u"Title by Language"),
        required=False)
示例#40
0
from interfaces import _, IEmailListFactory, IEmailList


class EmailList(object):
    interface.implements(IEmailList)

    title = None

    id = None

    name = None

    def __init__(self, name='', title=''):
        self.name = unicode(name)
        self.title = unicode(title)


class EmailListFactory(object):
    interface.implements(IEmailListFactory)

    title = None

    name = None

    def __call__(self):
        return EmailList(self.name, self.title)


registerFactoryAdapter(IEmailList, EmailList)
示例#41
0
                            required=False)

    tal_statement = schema.ASCIILine(title=_(u"TAL expression"),
                                     required=True,
                                     description=_(u'variables available include "item":catalog brain, "object": context object, "folder": parent of object if object is not a folder. e.g. "python:item.getObject().getBocy()"'),
                                     constraint=validate_tal)

    css_class = schema.ASCIILine(title=_(u"Additional CSS classes"),
                                 required=False,
                                 constraint=validate_class)


class CustomFieldDefinition(object):
    implements(ICustomFieldDefinition)

registerFactoryAdapter(ICustomFieldDefinition, CustomFieldDefinition)



def ListingViewVocabulary(context):
    terms = []
    reg = queryUtility(IRegistry)
    if reg is not None:
        proxy = ComplexRecordsProxy(reg, IListingControlPanel, prefix='collective.listingviews',
                                key_names={'views': 'id'})
        for view in proxy.views:
            terms.append(SimpleVocabulary.createTerm(view.id, view.id, view.name))
    return SimpleVocabulary(terms)


def MetadataVocabulary(context):
    active = FieldProperty(IResource['active'])
    compass_effort = FieldProperty(IResource['compass_effort'])

    __name__ = None
    __parent__ = None

    def getId(self):
        return self.__name__ or ''

    def __repr__(self):
        return '<%s (%s as %s)>' % (self.__class__.__name__,
                                    self.user_id,
                                    self.role)


registerFactoryAdapter(IResource, Resource)


class Environment(SimpleItem):

    implements(IEnvironment)

    name = FieldProperty(IEnvironment['name'])
    env_type = FieldProperty(IEnvironment['env_type'])
    url = FieldProperty(IEnvironment['url'])

    __name__ = None
    __parent__ = None

    def getId(self):
        return self.__name__ or ''
# -*- coding: utf-8 -*-

from zope import schema
from zope.interface import Interface, implements

from z3c.form.object import registerFactoryAdapter

from plone.registry.field import PersistentField

from collective.portaltabs import messageFactory as _

class IPortalActionCategory(Interface):
    category_id = schema.ASCIILine(title=_(u"Category ID"), required=True)
    category_title = schema.TextLine(title=_(u"Title to display"),
                                     description=_('help_category_title',
                                                   default="Will be displayed in the relative control panel fieldset"),
                                     required=True)

class PortalActionCategory(object):
    implements(IPortalActionCategory)

    def __init__(self, category_id=None, category_title=u''):
        self.category_id = category_id
        self.category_title = category_title

class PersistentObject(PersistentField, schema.Object):
    pass

registerFactoryAdapter(IPortalActionCategory, PortalActionCategory)