def test_ctor_explicit(self): from zope.schema import Text from zope.schema._compat import u field = Text( __name__='testing', description=u('DESCRIPTION'), default=u('DEFAULT'), readonly=True, required=True, ) cname = self._getTargetClass().__name__ prop = self._makeOne(field, name='override') self.assertTrue(isinstance(prop.field, field.__class__)) self.assertFalse(prop.field is field) self.assertEqual(prop.field.__name__, '__st_testing_st') self.assertEqual(prop.__name__, '__st_testing_st') self.assertEqual(getattr(prop, '_%s__name' % cname), 'override') self.assertEqual(prop.description, field.description) self.assertEqual(prop.default, field.default) self.assertEqual(prop.readonly, field.readonly) self.assertEqual(prop.required, field.required)
class IGSContentPageVersion(Interface): """ Schema for a content page """ id = ASCIILine( title='Identifier', # lint:ok description='The identifier of the version.', required=True) title = TextLine(title='Title', description='The title of the page, which will appear in ' 'the title bar of the browser.', required=True) content = Text(title='Content', description='The content of this page.', required=False) published = Bool(title='Publish', description='If you publish the change it will be shown ' 'to people by default.', required=True, default=True) editor = TextLine(title='Editor ID', description='The identifier of the user who last edited ' 'this Page', required=False, default='') parentVersion = ASCIILine( title='Parent Version ID', description='The identifier of the page version that this ' 'version was based on.', required=False, default=to_ascii('')) creationDate = Datetime( title='Creation Date', description='The date that the version was created', required=False)
class ICookiePolicySchema(Interface): """ Global statusmessage overlay configuration """ TCP_enabled = Bool( title=_(u"Enable Global statusmessage overlay"), default=True, required=False, ) TCP_title = TextLine( title=_(u'Title'), default=_(u'This Site Uses Cookies'), description=_( u'help_tcp_title', default=u"Enter the title for the Global statusmessage overlay", ), required=True, ) TCP_message = Text( title=_(u'Message'), description=_( u'help_tcp_message', default= (u"Enter the message for the Global statusmessage overlay. This may " u"contain HTML"), ), required=True, ) TCP_submit_button = TextLine( title=_(u'Submit button'), default=_(u'OK'), description=_( u'help_tcp_submit_button', default= u"Enter the title for the Global statusmessage overlay submit button.", ), required=True, )
def test___provides___w_field_w_provides(self): from zope.interface import implementedBy from zope.interface import providedBy from zope.interface.interfaces import IAttribute from zope.interface.interfaces import IMethod from zope.schema import Text # When wrapping a field that provides stuff, # we provide the same stuff, with the addition of # IMethod at the correct spot in the IRO (just before # IAttribute). field = Text() field_provides = list(providedBy(field)) wrapped = self._makeOne(field) wrapped_provides = list(providedBy(wrapped)) index_of_attribute = field_provides.index(IAttribute) expected = list(field_provides) expected.insert(index_of_attribute, IMethod) self.assertEqual(expected, wrapped_provides) for iface in list(implementedBy(self._getTargetClass())): self.assertIn(iface, wrapped_provides)
class IGitRepositoryModerateAttributes(Interface): """IGitRepository attributes that can be edited by more than one community. """ date_last_modified = exported( Datetime(title=_("Date last modified"), required=True, readonly=True)) reviewer = exported( PublicPersonChoice( title=_("Review Team"), required=False, readonly=False, vocabulary="ValidBranchReviewer", description=_("The reviewer of a repository is the person or " "exclusive team that is responsible for reviewing " "proposals and merging into this repository."))) description = exported( Text(title=_("Description"), required=False, readonly=False, description=_("A short description of this repository.")))
class ILinkSchema(Interface): title = TextLine( title=_(u'Title'), required=False, missing_value=u'') language = TextLine( title=_(u'Language'), required=False, missing_value=u'', max_length=2) description = Text( title=_(u'Description'), required=False, missing_value=u'') remote_url = BytesLine( title=_(u'URL'), required=False, missing_value=u'')
class ILocalGroup(Interface): """Local principals group interface""" containers(IGroupsFolderPlugin) group_id = TextLine( title=_("Group ID"), description=_("This ID should be unique between all groups"), required=True, readonly=True) title = TextLine(title=_("Title"), description=_("Public label of this group"), required=True) description = Text(title=_("Description"), required=False) principals = PrincipalsSetField( title=_("Group principals"), description=_("IDs of principals contained in this group"), required=False, default=set())
class ICustomScript(IAction): """Executes a Python script for form data""" form.read_permission(ProxyRole=MODIFY_PORTAL_CONTENT) form.write_permission(ProxyRole=EDIT_PYTHON_PERMISSION) ProxyRole = Choice( title=_(u'label_script_proxy', default=u'Proxy role'), description=_(u'help_script_proxy', default=u'Role under which to run the script.'), default=u'none', required=True, vocabulary=getProxyRoleChoices, ) form.read_permission(ScriptBody=MODIFY_PORTAL_CONTENT) form.write_permission(ScriptBody=EDIT_PYTHON_PERMISSION) ScriptBody = Text( title=_(u'label_script_body', default=u'Script body'), description=_(u'help_script_body', default=u'Write your script here.'), default=DEFAULT_SCRIPT, required=False, missing_value=u'', )
class IDatagridField(IBaseField): """ Text field schema """ widget = Choice(vocabulary=SimpleVocabulary.fromItems([ ("Always dynamic", "REGULAR"), ("Static in read mode", "READ_STATIC"), ]), title=u'Widget', description=u'Field rendering', default="REGULAR", required=True) associated_form = Choice( vocabulary='Products.CMFPlomino.fields.vocabularies.get_forms', title=u'Associated form', description=u'Form to use to create/edit rows', required=False) field_mapping = TextLine( title=u'Columns/fields mapping', description= u'Field ids from the associated form, ordered as the columns, separated by commas', required=False) jssettings = Text(title=u'Javascript settings', description=u'jQuery datatable parameters', default=u""" "aoColumns": [ { "sTitle": "Column 1" }, { "sTitle": "Column 2", "sClass": "center" } ], "bPaginate": false, "bLengthChange": false, "bFilter": false, "bSort": false, "bInfo": false, "bAutoWidth": false """, required=False)
class IPermission(Interface): """A permission object. Note that the ZCML ``<permission>`` directive restricts the ``id`` to be an identifier (a dotted name or a URI), but this interface allows any native string. """ id = NativeStringLine( title=_("Id"), description=_("Id as which this permission will be known and used."), readonly=True, required=True) title = TextLine(title=_("Title"), description=_("Provides a title for the permission."), required=True) description = Text( title=_("Description"), description=_("Provides a description for the permission."), required=False)
class ILocaleVersion(Interface): """Represents the version of a locale. The locale version is part of the ILocaleIdentity object. """ number = TextLine(title=u"Version Number", description=u"The version number of the locale.", constraint=re.compile(r'^([0-9].)*[0-9]$').match, required=True, readonly=True) generationDate = Date( title=u"Generation Date", description=u"Specifies the creation date of the locale.", constraint=lambda date: date < datetime.now(), readonly=True) notes = Text( title=u"Notes", description=u"Some release notes for the version of this locale.", readonly=True)
class IAddForm(Interface): """ Interface for creating a prenotazione """ fullname = TextLine( title=_('label_fullname', u'Fullname'), default=u'', ) subject = Text( title=_('label_subject', u'Subject'), default=u'', required=False, ) booking_date = Datetime( title=_('label_booking_time', u'Booking time'), default=None, ) agency = TextLine( title=_('label_agency', u'Agency'), description=_('description_agency', u'If you work for an agency please specify its name'), default=u'', required=False, ) phone = TextLine( title=_('label_phone', u'Phone number'), required=False, default=u'', ) email = TextLine( title=_('label_email', u'Email'), default=u'', ) captcha = Captcha( title=_('label_captcha', u'Type the code from the picture shown below.'), default='', )
class IGoogleAuthenticatorSettings(Interface): """ Global Google Authenticator settings. """ ska_secret_key = TextLine( title=_("Secret Key"), description=_( "Enter your secret key for the site here. When choosing a secret key, " "think of it as some sort of a password."), required=False, default=u'', ) globally_enabled = Bool( title=_("Globally enabled"), description= _("If checked, globally enables the two-step verification for all users; " "otherwise - each user configures it himself. Note, that unchecking the " "checkbox does not disable the two-step verification for all users." ), required=False, default=True, ) ip_addresses_whitelist = Text( title=_("White-listed IP addresses"), description=_( "Two-step verification will be ommit for users that log in from white " "listed addresses."), required=False, default=u'', ) fieldset(None, label=None, fields=[ 'ska_secret_key', 'globally_enabled', 'ip_addresses_whitelist', ])
class IArchiveSubscriberUI(Interface): """A custom interface for user interaction with archive subscriptions. IArchiveSubscriber uses a datetime field for date_expires, whereas we simply want to use a date field when users create or edit new subscriptions. """ subscriber = PersonChoice( title=_("Subscriber"), required=True, vocabulary='ValidPersonOrTeam', description=_("The person or team to grant access.")) date_expires = Date(title=_("Date of Expiration"), required=False, description=_( "The date when the access will expire. " "Leave this blank for access that should " "never expire.")) description = Text(title=_("Description"), required=False, description=_("Optional notes about this access."))
class IGSFileResultsContentProvider(IContentProvider, IGSSearchResults): """The GroupServer File Results Content Provider""" pageTemplateFileName = Text( title="Page Template File Name", description="""The name of the ZPT file that is used to render the results.""", required=False, default="browser/templates/fileResults.pt") searchPostedFiles = Bool( title='Search Posted Files', description='If True, the files that the users have posted to' 'their groups are searched.', required=False, default=True) searchSiteFiles = Bool( title='Search Site Files', description='If True, the files in the Web site, outside those' 'posted to groups, are searched.', required=False, default=True)
class IFavoriteSchema(Interface): title = TextLine( title=_(u'Title'), required=False, missing_value=u'') language = TextLine( title=_(u'Language'), required=False, missing_value=u'', max_length=2) description = Text( title=_(u'Description'), required=False, missing_value=u'') remote_url = BytesLine( title=_(u'URL'), description=_(u'URL relative to the site root.'), required=False, missing_value=u'')
class RegisterProposalSchema(Interface): """The schema to define the form for registering a new merge proposal.""" target_branch = Choice( title=_('Target branch'), vocabulary='Branch', required=True, readonly=True, description=_( "The branch that the source branch will be merged into.")) prerequisite_branch = Choice( title=_('Prerequisite branch'), vocabulary='Branch', required=False, readonly=False, description=_( 'A branch that should be merged before this one. (Its changes' ' will not be shown in the diff.)')) comment = Text( title=_('Description of the change'), required=False, description=_('Describe what changes your branch introduces, ' 'what bugs it fixes, or what features it implements. ' 'Ideally include rationale and how to test. ' 'You do not need to repeat information from the commit ' 'message here.')) reviewer = copy_field( ICodeReviewVoteReference['reviewer'], required=False) review_type = copy_field( ICodeReviewVoteReference['review_type'], description=u'Lowercase keywords describing the type of review you ' 'would like to be performed.') commit_message = IBranchMergeProposal['commit_message'] needs_review = Bool( title=_("Needs review"), required=True, default=True, description=_( "Is the proposal ready for review now?"))
class IGSViewingInfo(Interface): """Information about viewing areas of a group. There are three areas that can have viewing privilages seperate to those specified for the entire group: * Messages, * Chat, and * The list of members. Information about the visibility of each of the areas, and the entire group, is provided by the methods defined here. """ context = Field(title='Context', description='Context for the viewing information') whoCanView = Text( title='Who Can View the Area of the Group', description='A description of the users who can view the ' 'particular area of the group', readonly=True) def can_view(user): """Can the user view the area? ARGUMENTS "user": A user. RETURNS "True" if the user can view the group and the area; "False" otherwise. SIDE EFFECTS None """ def status(user): """The status of the user, with respect to viewing the area of the
def test_field_event_update(self): from zope.schema import Text from zope.interface.verify import verifyObject from zope.event import subscribers from zope.schema.interfaces import IFieldUpdatedEvent from zope.schema.fieldproperty import FieldUpdatedEvent field = Text( __name__='testing', description=u'DESCRIPTION', default=u'DEFAULT', required=True, ) prop = self._makeOne(field=field) class Foo(object): testing = prop foo = Foo() log = [] subscribers.append(log.append) foo.testing = u'Bar' foo.testing = u'Foo' self.assertEqual(len(log), 2) event = log[1] self.assertTrue(isinstance(event, FieldUpdatedEvent)) self.assertTrue(verifyObject(IFieldUpdatedEvent, event)) self.assertEqual(event.object, foo) self.assertEqual(event.field, field) self.assertEqual(event.old_value, u'Bar') self.assertEqual(event.new_value, u'Foo') # BBB, but test this works. self.assertEqual(event.inst, foo) marker = object() event.inst = marker self.assertEqual(event.inst, marker) self.assertEqual(event.object, marker)
class IEmail(Interface): """An email""" from_address = TextLine(title=_(u'From'), description=_(u'The sender address')) to_addresses = List(title=_(u'To'), description=_(u'Recipient addresses'), value_type=TextLine(title=_(u'Recipient address')), min_length=1) body = Text(title=_(u'Body'), description=_(u'Body of the message')) subject = TextLine(title=_(u'Subject'), description=_(u'Subject of the message'), required=False) status_code = TextLine( title=_(u'Status'), description=_(u'Code for the status of the message'), required=False) status_parameters = Dict( title=_(u'Status Parameters'), description=_(u'Parameters for the status of the message'), key_type=TextLine(title=_(u'Parameter key')), value_type=TextLine(title=_(u'Parameter value')), required=False) time_created = Datetime( title=_(u'Created on'), description=_(u'Date and time when the message was created')) time_sent = Datetime( title=_(u'Sent on'), description=_(u'Date and time when the message was sent'), required=False)
class IBugTrackerComponentGroup(Interface): """A collection of components in a remote bug tracker. Some bug trackers organize sets of components into higher level groups, such as Bugzilla's 'product'. """ export_as_webservice_entry() id = Int(title=_('ID')) name = exported( Text(title=_('Name'), description=_('The name of the bug tracker product.'))) components = exported( CollectionField(title=_('Components.'), value_type=Reference(schema=IBugTrackerComponent))) bug_tracker = exported(Reference(title=_('BugTracker'), schema=IBugTracker)) @operation_parameters(component_name=TextLine( title=u"The name of the remote software component to be added", required=True)) @export_write_operation() def addComponent(component_name): """Adds a component to be tracked as part of this component group"""
class ISubscribeNewsletterForm(Schema): email = TextLine( title=_(u"E-mail address"), required=True, ) gdpr = schema.Bool( title=_('Activer l\'abonnement'), description= _(u'En cochant la case, vous acceptez que les informations que vous fournissez soient traitées conformément à notre <a href="gdpr-view">politique de confidentialité</a>' ), default=False, required=True) format = Choice( title=_(u"Format"), required=True, vocabulary=formats, ) title = TextLine(required=False, ) message = Text(required=False, )
class IEventsDirectory(IDirectory): """Extends the seantis.dir.base.directory.IDirectory""" image = NamedImage(title=_(u'Image'), required=False, default=None) searchable('terms') terms = Text(title=_(u'Terms and Conditions'), description=_( u'If entered, the terms and conditions have ' u'to be agreed to by anyone submitting an event.'), required=False, default=None) form.widget(terms=WysiwygFieldWidget) submit_event_link = Website( title=_(u'Event Report Link'), description=_( u'If a link is given, the "submit event" link on the directory ' u'will point to that link, instead of the internal submit form. ' u'If left empty, the internal submit form remains. ' u'Use this, if events should be submitted on an external website. ' ), required=False, default=None)
def test_field_event(self): from zope.schema import Text from zope.schema._compat import u from zope.event import subscribers from zope.schema.fieldproperty import FieldUpdatedEvent log = [] subscribers.append(log.append) self.assertEqual(log, []) field = Text( __name__='testing', description=u('DESCRIPTION'), default=u('DEFAULT'), readonly=True, required=True, ) self.assertEqual(len(log), 6) event = log[0] self.assertTrue(isinstance(event, FieldUpdatedEvent)) self.assertEqual(event.inst, field) self.assertEqual(event.old_value, 0) self.assertEqual(event.new_value, 0) self.assertEqual( [ev.field.__name__ for ev in log], ['min_length', 'max_length', 'title', 'description', 'required', 'readonly'])
class ISMSAuthenticatorSettings(Interface): """ Global SMS Authenticator settings. """ # Local settings globally_enabled = Bool( title=_("Globally enabled"), description= _("If checked, globally enables the two-step verification for all users; " "otherwise - each user configures it himself. Note, that unchecking the " "checkbox does not disable the two-step verification for all users." ), required=False, default=True, ) ip_addresses_whitelist = Text( title=_("White-listed IP addresses"), description=_( "Two-step verification will be ommit for users that log in from white " "listed addresses."), required=False, default=u'', ) fieldset('main', label=_("Main"), fields=[ 'globally_enabled', 'ip_addresses_whitelist', ]) # Twilio settings twilio_number = TextLine( title=_("Twilio number"), description=_("Enter your Twilio (phone) number."), required=True, default=u'', ) twilio_account_sid = TextLine( title=_("Twilio AccountSID"), description=_("Enter your Twilio AccountSID."), required=True, default=u'', ) twilio_auth_token = TextLine( title=_("Twilio AuthToken"), description=_("Enter your Twilio AuthToken."), required=True, default=u'', ) fieldset('twilio', label=_("Twilio"), fields=[ 'twilio_number', 'twilio_account_sid', 'twilio_auth_token', ]) # Security settings ska_secret_key = TextLine( title=_("Secret Key"), description=_( "Enter your secret key for the site here. When choosing a secret key, " "think of it as some sort of a password."), required=False, default=u'', ) ska_token_lifetime = Int( title=_("Token lifetime"), description=_("Authentication token lifetime in seconds."), required=False, default=300, # 15 minutes ) fieldset('security', label=_("Security"), fields=[ 'ska_secret_key', 'ska_token_lifetime', ])
class INode(Interface): """Node im- and exporter. """ node = Text(description=u'Im- and export the object as a DOM node.')
class ISiteSchema(Interface): site_title_1 = TextLine(title=_(u'Site title (First Line)'), description=_(u'First line of site title'), required=False, default=u'') site_title_2 = TextLine(title=_(u'Site title (Second Line)'), description=_(u'Second line of site title'), default=u'') site_orgao = TextLine(title=_(u'Department'), description=_(u'Name of Ministry or Department ' u'to which this site is subject.'), required=False, default=u'') url_orgao = TextLine( title=_(u'Url ID of Department'), description=_( u'Url ID for Ministry or Department to which this site is subject.' ), required=False, default=u'') site_description = Text( title=_(u'Site description'), description=_(u'The site description is available ' u'in syndicated content and in search engines. ' u'Keep it brief.'), default=u'', required=False) exposeDCMetaTags = Bool( title=_(u'Expose Dublin Core metadata'), description=_(u'Exposes the Dublin Core properties as metatags.'), default=False, required=False) display_pub_date_in_byline = Bool( title=_(u'Display publication date in about information'), description=_(u'Displays content publication date on site pages.'), default=False, required=False) enable_sitemap = Bool(title=_(u'Expose sitemap.xml.gz'), description=_( u'Exposes your content as a file ' u'according to the sitemaps.org standard. You ' u'can submit this to compliant search engines ' u'like Google, Yahoo and Microsoft. It allows ' u'these search engines to more intelligently ' u'crawl your site.'), default=False, required=False) webstats_js = SourceText( title=_(u'JavaScript for web statistics support'), description=_(u'For enabling web statistics support ' u'from external providers (for e.g. Google ' u'Analytics). Paste the code snippets provided. ' u'It will be included in the rendered HTML as ' u'entered near the end of the page.'), default=u'', required=False)
def _makeOne(self, field=None): from zope.schema import Text if field is None: field = Text(__name__='testing') return self._getTargetClass()(field)
class IRevisionProperty(Interface): """A property on a Bazaar revision.""" revision = Attribute("The revision which has this property.") name = TextLine(title=_("The name of the property."), required=True) value = Text(title=_("The value of the property."), required=True)
class IComponentsSetupSchema(Interface): """Schema for components setup views. """ body = Text(title=u'Settings')