class IFormComponents(Interface): """ Adapter interface for an object providing access to the respective components making up the form definition: * An ordered tuple of names of fieldsets made up from the definition itself and field groups contained. * An (unordered) mapping / dict of name to group (IFieldGroup or IFieldDefinition -- anything providing either) values. Titles and schema for the groups should be obtained by calling code using this adapter, and are not provided by the adapter interface itself. This also means the responsibility to wrap field group schema declared as a grid aslo is ommitted from the scope of this adapter. """ names = schema.Tuple( title=u'Fieldset names', value_type=schema.BytesLine(), defaultFactory=list, # req zope.schema > 3.8.0 readonly=True, # read-only property ) groups = schema.Dict( title=u'Fieldset groups', key_type=schema.BytesLine(), value_type=schema.Object(schema=IDefinitionBase), defaultFactory=dict, # req zope.schema > 3.8.0 readonly=True, # read-only dict, though groups are mutable )
class IDefinitionBase(form.Schema, ISchemaProvider, IAttributeUUID): """Base for form, form-group definitions""" form.omitted('signature') # instance attribute, not editable form field signature = schema.BytesLine( title=_(u'Schema signature'), description=_(u'MD5 hexidecimal digest hash of entry_schema XML.'), default=DEFAULT_SIGNATURE, required=False, ) form.omitted('signature_history') # attribute, not editable form field signature_history = schema.List( title=_(u'Signature history stack'), description=_(u'Chronologically-ordered list of MD5 hexidecimal ' u'digest hashes of entry_schema XML.'), value_type=schema.BytesLine(), defaultFactory=list, ) title = schema.TextLine( title=u'Title', description=u'Name of definition; this is used as a label displayed ' u'when binding forms to this definition, and also is ' u'used to help create a unique short name for the ' u'definition used in its URL.', required=True, ) description = schema.Text( title=u'Description', description=u'Optional description of this form definition.', required=False, ) form.widget(entry_schema=TextAreaFieldWidget) entry_schema = schema.Bytes( title=_(u'Form schema XML'), description=_(u'Serialized form schema XML.'), constraint=valid_xml_schema, default=DEFAULT_MODEL_XML, required=False, ) # NOTE: this field must be last in interface code: identifier collision form.omitted('schema') # instance attribute, but not editable form field schema = schema.Object( title=_(u'Form schema'), description=_(u'Form schema based upon entry_schema XML, usually ' u'a reference to a transient interface object ' u'looked up from persistent attribute self.signature.'), schema=IInterface, required=True, # implementations should provide empty default readonly=True, # read-only property, though object returned is mutable ) def schema_version(signature): """
class IOptionsDirective(Interface): type = schema.BytesLine(title=u"Options type", description=u"This is options type", required=False) prefix = schema.BytesLine(title=u"Options to include", description=u"This are options", required=True) default = schema.BytesLine(title=u"Options default", description=u"This are options default value", required=False)
class IOptions(Interface): prefix = schema.BytesLine(title=u"option", description=u"This is an option", required=True) type = schema.BytesLine(title=u"Options type", description=u"This is options type", required=False) default = schema.BytesLine(title=u"Options default", description=u"This is options default", required=False)
class ITemplateDirective(Interface): name = schema.BytesLine( title=u"Pasters assembly", description=u"This is a configuration of paster templates", required=True) order = schema.Int(title=u"template generation order", description=u"The template generation order", required=True) output = schema.BytesLine(title=u"template generation folder", description=u"The template generation folder", required=False)
class IOptionDirective(Interface): name = schema.BytesLine(title=u"option", description=u"This is an option", required=True) type = schema.BytesLine(title=u"Options type", description=u"This is options type", required=False) default = schema.BytesLine(title=u"Options default", description=u"This is options default", required=False) alias = schema.BytesLine( title=u"alias", description=u"Alias for option if it conflicts with another one", required=False)
class IOption(Interface): name = schema.BytesLine(title=u"option", description=u"This is an option", required=True) type = schema.BytesLine(title=u"Options type", description=u"This is options type", required=False) default = schema.BytesLine(title=u"Options default", description=u"This is options default", required=False) alias = schema.BytesLine( title=u"Option alias", description=u"This is option alias for conflict handling", required=False)
class IDataPoint(IAggregateDescription): """Data point contains single value and optional note and URI""" value = schema.Float( title=_(u'Number value'), description=_(u'Decimal number value.'), default=0.0, ) note = schema.Text( title=_(u'Note'), description=_(u'Note annotating the data value for this point.'), required=False, ) uri = schema.BytesLine( title=_(u'URI'), description=_(u'URI/URL or identifier to source of data'), required=False, ) sample_size = schema.Int( title=_(u'Sample size (N)'), description=u'Sample size, may be computed denominator of a ' u'population or subpopulation sampled.', required=False, ) def identity(): """
class IAggregateDescription(Interface): """ Mixin of fields related to aggregating multiple data points into a single descriptive aggretate point. All fields optional, and only considered relevant to aggregation of data from multiple sources or samples. 'distribution' attribute would have values that look like: [{ "value": 75.0, "sample_size": 8 }, { "value": 80, "sample_size": 10}] This data is sufficient to compute: - The sum of sample sizes. - The weighted mean. - The original numerator values as value/100.0 * sample_size - Presuming the value looks like a percentage. - The arithmetic mean. - Distribution plot. - Median, quartile boundary, and therefore box plot. """ distribution = schema.List( title=_(u'Distribution data'), description=_(u'List of dict containing value, sample size for each ' u'sample in aggregation.'), required=False, value_type=schema.Dict(key_type=schema.BytesLine(), value_type=schema.Object( schema=Interface, description=u'Value, may be int or float')))
class IZopeConfigure(Interface): """The ``zope:configure`` Directive The zope configuration directive is a pure grouping directive. It doesn't compute any actions on it's own. Instead, it allows a package to be specified, affecting the interpretation of relative dotted names and file paths. It also allows an i18n domain to be specified. The information collected is used by subdirectives. It may seem that this directive can only be used once per file, but it can be applied whereever it is convenient. """ package = config.fields.GlobalObject( title=u"Package", description=u"The package to be used for evaluating relative imports " u"and file names.", required=False) i18n_domain = schema.BytesLine( title=u"Internationalization domain", description=u"This is a name for the software project. It must be a " u"legal file-system name as it will be used to contruct " u"names for directories containing translation data. " u"\n" u"The domain defines a namespace for the message ids " u"used by a project.", required=False)
class ICSVColumn(Interface): """ Abstraction for a CSV column specification used for a set of records. """ name = schema.BytesLine( title=u'Field column name', description=u'Column name, based on field name', required=True, ) title = schema.TextLine( title=u'Title', description=u'Column / field title', default=u'', required=False, ) field = schema.Object( title=u'Field object', description=u'Field object from interface', schema=Interface, ) def get(record): """Return column value as string for a record or an empty string."""
class IPasterConfiguration(Interface): name = schema.BytesLine( title=u"name", description=u"This is a configuration of paster templates", required=True) templates = schema.Dict(title=u"templates", ) plugins = schema.List(title=u"plugins", )
class IFile(Interface): metadata('extension', 'md5', 'contentType', 'filename') index('contentType', type='text') contentType = schema.BytesLine( title=u'Content Type', description=u'The content type identifies the type of data.', default=b'', required=False ) index('filename', type='text') filename = schema.TextLine(title=u'Filename', required=False, default=None) data = schema.Bytes( title=u'Data', description=u'The actual content.', required=False, ) index('extension', type='text') extension = schema.TextLine( title='Extension of the file', default='') index('md5', type='text') md5 = schema.TextLine( title='MD5', default='') def get_size(): """Return the byte-size of the data of the object."""
class ISchemaSignedEntity(IRecord): """ An entity that is signed with the signature of a persisted dynamic interface/schema object. The signature is the md5 hexidecimal digest of the XML serialization of the schema provided by plone.supermodel. Entity is also: * a location with __name__ and __parent__ attributes of ILocation ancestor interface (via IRecord). __parent__ should normatively be the content-ish container of the entity records, but may be some other context. * A record with a string-representation UUID attribute record_uid (via IRecord). """ signature = schema.BytesLine( title=u'Schema signature', description=u'MD5 hex-digest signature of XML serialized schema', required=False, ) def sign(schema, usedottedname=False): """
class ITimeSeriesChart(IBaseChart, ITimeSeriesCollection): """Chart content item; container for sequences""" form.order_after(auto_crop='frequency') auto_crop = schema.Bool( title=u'Auto-crop to completed data?', description=u'If data contains sequential null values (incomplete ' u'or no data calculable) on the right-hand of a ' u'time-series plot, should that right-hand side ' u'be cropped to only show the latest meaningful ' u'data? The default is to crop automatically.', default=True, ) form.order_after(force_crop='auto_crop') force_crop = schema.Bool( title=u'Forced crop of data?', description=u'If data points are available before a specified ' u'start date or after a specified end-date, should ' u'those points be excluded from the visualization?', default=False, ) form.omitted('label_overrides') label_overrides = schema.Dict( key_type=schema.Date(), value_type=schema.BytesLine(), required=False, ) def series(): """
class IColumn(interface.Interface): name = schema.BytesLine( title=u'Name', description=(u'Name used for column in options of a table ' u'configuration. Must be unique within any set of ' u'columns passed to a table formatter.'), constraint=pythonLikeNameConstraint, ) title = schema.TextLine( title=u'Title', description=u'The title of the column, used in configuration ' u'dialogs.', ) def renderHeader(formatter): """Renders a table header. 'formatter' - The IFormatter that is using the IColumn. Returns html_fragment, not including any surrounding <th> tags. """ def renderCell(item, formatter): """Renders a table cell.
class IDefinitionHistory(Interface): """ Metadata about any changes to a form definition or its contents. Effectively a singular log entry; if multiple edits happen in one transaction, they should have distinct IDefinitionHistory objects in a log or list of history. """ namespace = schema.BytesLine( title=u'Namespace', description=u'ID or path of modified object relative to definition.', default='', # empty string is path to definition itself. ) signature = schema.BytesLine( title=u'Schema signature', description=u'Schema signature at modification time, if applicable.', required=False, ) modified = schema.Datetime( title=u'Modification time', description=u'Date/time stamp (datetime object) of modification.', defaultFactory=datetime.now, # requires zope.schema >= 3.8.0 ) modification = schema.Choice( title=u'Modification type', vocabulary=mkvocab(( ('modified', u'Definition modified'), ('schema', u'Definition (primary) schema modified'), ('group-added', u'Field group added'), ('group-modified', u'Field group definition modified'), ('group-deleted', u'Field group deleted'), ('group-schema', u'Field group schema modified'), ('formset-added', u'Form set added'), ('formset-modified', u'Form set modified'), ('formset-deleted', u'Form set deleted'), )), default='modified', ) note = schema.Text( title=u'Note', description=u'Note or log message about modification.', required=False, )
class IGroupDirective(Interface): name = schema.BytesLine( title=u"Pasters assembly", description=u"This is a configuration of paster templates", required=True) order = schema.Int(title=u"group display order", description=u"The group display order", required=False)
class IInclude(Interface): """The ``include``, ``includeOverrides`` and ``exclude`` directives These directives allows you to include or preserve including of another ZCML file in the configuration. This enables you to write configuration files in each package and then link them together. """ file = schema.BytesLine( title=u"Configuration file name", description=u"The name of a configuration file to be included/excluded, " u"relative to the directive containing the " u"including configuration file.", required=False, ) files = schema.BytesLine( title=u"Configuration file name pattern", description=u""" The names of multiple configuration files to be included/excluded, expressed as a file-name pattern, relative to the directive containing the including or excluding configuration file. The pattern can include: - ``*`` matches 0 or more characters - ``?`` matches a single character - ``[<seq>]`` matches any character in seq - ``[!<seq>]`` matches any character not in seq The file names are included in sorted order, where sorting is without regard to case. """, required=False, ) package = config.fields.GlobalObject( title=u"Include or exclude package", description=u""" Include or exclude the named file (or configure.zcml) from the directory of this package. """, required=False, )
class IPluginDirective(Interface): name = schema.BytesLine( title=u"plugin name", description=u"this is a plugin name to execute if found", required=True) order = schema.Int(title=u"plugin order", description=u"The plugin order", required=False)
class IMembershipModifications(Interface): """ User modifications adapter: an unordered queue for bulk changes that are applied to a workspace context: * context is workspace, which is adapted to IMembershipModifications; * Each assignment or un-assignment is role-group specific, and is queued until self.apply() is called. """ planned_assign = schema.Dict( description=u'Queue of additions to assigned users, to be ' 'applied to context when self.apply() is called. ' 'Should be emptied on successful self.apply(). ' 'Keys are role names like "viewers"; values are ' 'each a set of string user names.', key_type=schema.BytesLine(), value_type=schema.Set(value_type=schema.BytesLine()), ) planned_unassign = schema.Dict( description=u'Queue of additions to assigned users, to be ' 'applied to context when self.apply() is called. ' 'Should be emptied on successful self.apply(). ' 'Keys are role names like "viewers"; values are ' 'each a set of string user names.', key_type=schema.BytesLine(), value_type=schema.Set(value_type=schema.BytesLine()), ) def assign(username, group=BASE_GROUPNAME): """ Queue an assignment of a user to a role group, or confirm existing assignment if already assigned to that group. """ def unassign(username, group=BASE_GROUPNAME): """ Queue an removal of a user from a role group, or confirm existing assignment if already assigned to that group. """ def apply(): """
class ITestSchemaIndexes(Interface): """Interface wtih schema fields for index enumeration tests""" name = schema.TextLine() url = schema.BytesLine() ignore = schema.Bytes() biography = schema.Text() number = schema.Int() date = schema.Date() subjects = schema.List(value_type=schema.TextLine())
class IProjectSnapshot(Interface): name = schema.BytesLine() title = schema.TextLine() month = schema.Choice(vocabulary=_mkvocab(MONTHS.values()), ) date = schema.Date() all_users = schema.Set() managers = schema.Set() form_users = schema.Set() project_count = schema.Int(constraint=lambda v: v >= 0) team_count = schema.Int(constraint=lambda v: v >= 0)
class IGroup(Interface): name = schema.BytesLine( title=u"Pasters assembly", description=u"This is a configuration of paster templates", required=True) order = schema.Int(title=u"template generation order", description=u"The group display order", required=True) options = schema.List(title=u"options", ) single_options = schema.List(title=u"single options", ) exclude_options = schema.List(title=u"exclude options", )
class IWorkspaceRoster(IWorkspaceGroup): """ A roster of the base workspace members group (usually called 'viewers') referencing more specialized groups in the groups mapping. """ groups = schema.Dict( title=u'Groups', description=u'Specific project or workspace groups', key_type=schema.BytesLine(title=u'Group id'), value_type=schema.Object(schema=IWorkspaceGroup), defaultFactory=dict, # requires zope.schema >= 3.8.0 ) def unassign(username, role=None): """ Removes a user from roster, or possibly just one role group within the workgroup's roster, if provided. If role is None or is equal to 'viewers', the user will be: - Removed from all groups in workspace; - Removed from all all groups in all contained workspaces; this is recursive and irrespective of depth. If a role group name other than 'viewers' is passed, that group will be obtained by the roster, and the user will have that role unassigned, if applicable. Raise ValueError if user is not contained in the workspace roster. Unassigning a user from the base group also unassigns them recursively from contained groups. """ def can_purge(username): """ Return true if user is not member of other projects. All of the following conditions must be met to return True: - The adaptation context is a top-level project workspace; - The user is not a member of other projects, that is: - The user is a member of only one project; - And that one project is the current context. Always returns False in the context of a non-project workspace. Note: it is possible to purge a user at the project level, even if they have membership in contained workspaces. """ def purge_user(username): """
class ISimpleForm(IBaseForm): """ Simple form is a content item that provides one form entry record providing IFormEntry. """ form.omitted('data') data = schema.Dict( title=u'Data mapping', description=u'Map data from fieldset name to record.', key_type=schema.BytesLine(title=u'Fieldset name'), value_type=schema.Object(schema=IFormEntry), defaultFactory=PersistentDict, # requires zope.schema >= 3.8.0 )
class IEditarUsuario(Interface): usuario = schema.BytesLine(title=u'Usuario', required=True) password = schema.Password(title=u'Contraseña', required=False) confirmar_password = schema.Password(title=u'Confirmar contraseña', required=False) nombre_real = schema.BytesLine(title=u'Nombre real', required=True) rol = schema.Choice(title=u'Rol del usuario', values=[u'empleado', u'administrador'], required=False) seccion = schema.Choice(title=u'Seccion para el empleado', values=[u'seccionejemplo1', u'seccionejemplo2'], required=False) @invariant def matching_passwords(form): if form.confirmar_password != form.password: raise Invalid('Passwords does not match') @invariant def valid_login(form): if not re.compile('^[a-z0-9]+$').match(form.usuario): raise Invalid('Invalid user name, only characters in [a-z0-9] ' 'are allowed')
class IRecord(ILocation, IAttributeUUID): """ A record is an object with a unique id (RFC 4122 UUID) stored in string form as an attribute or property of the object, with a location context (ILocation __parent__ and __name__) attributes. Note: IAttributeUUID interface is a normalizing proxy to self.record_uid value. """ record_uid = schema.BytesLine( title=u'Record UID', description=u'Record UUID in string format', defaultFactory=lambda: str(uuid.uuid4()), # random UUID )
class IComposedQuery(ISetOperationSpecifier, ISequence): """ An iterable sequence containing filter groups, with a set operation that be specified for use in composing a final query from the groups for use in repoze.catalog (when called). The composition relationships of all the parts is shown below: IComposedQuery <>-. : (sequence) .--<> IFilterGroup ---' (sequence) : `--- IRecordFilter <>-. : (ordered mapping) IFieldQuery ----' """ name = schema.BytesLine( title=u'Query name', description=u'Query name, either numerator or denominator.', constraint=lambda v: str(v) in ('numerator', 'denominator'), ) def reset(): """ Empty filter contents of all queries and set operator to default of 'union'. """ def move(item, direction='top'): """ Given item as either UUID for a filter group, or as a group object contained wihtin this composed query sequence, move its order according to the specified direction, which must be one of: 'up', 'down', 'top', 'bottom'. """ def build(schema): """ Construct and return a repoze.catalog query for all groups by composing the query for each group using the set operation specified for this composed query. This is done in the context of the schema passed, which is passed to IRecordFilter.build(). """ def requires_advanced_editing(): """
class IExportForm(model.Schema): directory = schema.BytesLine( title=u'Directory name', description=u'Give name for the theme sub-directory, where ' u'the generated export should be saved to. ' u'If the directory already exists, ' u'its content may get overridden.', default=DEFAULT_ENABLED_PROFILE_NAME) directives.widget(steps=CheckBoxFieldWidget) steps = schema.List( title=u'Exported steps', description=u'Select the steps, which should be included in ' u'the export.', value_type=schema.Choice(title=u'Step name', source=genericSetupExportStepsSource), default=['content'])