def option(_context, name, value, type=None): # pylint: disable=W0622 grouping_context = _context.context if not type is None: field = type() value = field.fromUnicode(value) elif name in (IGNORE_OPTION, IGNORE_ON_READ_OPTION, IGNORE_ON_WRITE_OPTION, WRITE_AS_LINK_OPTION, WRITE_MEMBERS_AS_LINK_OPTION): field = Bool() value = field.fromUnicode(value) grouping_context.options[name] = value
def option(_context, name, value, type=None): # pylint: disable=W0622 grouping_context = _context.context if not type is None: field = type() value = field.fromUnicode(value) elif name in (IGNORE_OPTION, WRITE_AS_LINK_OPTION, WRITE_MEMBERS_AS_LINK_OPTION): field = Bool() value = field.fromUnicode(value) grouping_context.options[name] = value
class IRegisterDirectoryDirective(Interface): """Register directories with the global registry. """ name = PythonIdentifier(title=u'Name', description=u'Name of the directory.', required=True) directory = Path( title=u'Path', description=u'Path relative to the package. If not specified, ' u"'skins/<name>' is used.", required=False) recursive = Bool( title=u'Recursive?', description=u'False by default. If true, register all subdirectories ' u'as well.', required=False) ignore = Tokens( title=u'Ignore', description=u'Files and subdirectories that should be ignored. If ' u"not specified, 'CVS' and '.svn' are ignored.", value_type=ASCIILine(), required=False)
class IRegisterBundleDirective(Interface): title = MessageID( title=u'Title', description=u'Bundle title.', default=None, required=True) profiles = Tokens( title=u'Profiles', description=u'Generic setup profile names (without profile- prefix)', default=None, required=True, value_type=TextLine()) description = MessageID( title=u'Description', description=u'Optional description for the bundle.', default=u'', required=False) base = TextLine( title=u'Generic Setup base profile', description=u'Used as base profile when creating the site.' u' Defaults to %s' % _DEFAULT_PROFILE, default=_DEFAULT_PROFILE.decode('utf-8'), required=False) standard = Bool( title=u'Standard profile', description=u'Standard profiles are listed below' u' non-standard profiles.', default=False, required=False)
class IMessagingDirective(Interface): repository = \ TextLine(title=u"Repository type to use for the system repository.", required=True, ) reset_on_start = \ Bool(title=u"Erase all stored system resources on startup. This only " "has an effect in persistent repositories.", required=False)
class IOverrideRealm(Interface): active = Bool(title=u'Active', required=False, default=True) url = URI(title=u'URL to the Plone-Site', required=True) username = TextLine(title=u'Zope username', required=True) password = TextLine(title=u'Zope password', required=True)
class IFieldInfo(Interface): name = NativeStringLine(title=u"The field name", ) title = TextLine( title=u"Title", description=u"A short summary or label", default=u"", required=False, ) required = Bool(title=u"Required", description=u"Determines whether a value is required.", default=True) readonly = Bool(title=u"Read Only", description=u"Can the value be modified?", required=False, default=False)
class IFieldInfo(Interface): name = BytesLine(title=u("The field name"), ) title = TextLine( title=u("Title"), description=u("A short summary or label"), default=u(""), required=False, ) required = Bool(title=u("Required"), description=u("Determines whether a value is required."), default=True) readonly = Bool(title=u("Read Only"), description=u("Can the value be modified?"), required=False, default=False)
class IAnonymousObjectFactoryDirective(IBaseAnonymousObjectFactoryDirective): """ Defines the ``ext:anonymousObjectFactory`` directive. This directive registers a single :class:`nti.externaliaztion.interfaces.IAnonymousObjectFactory` for a single field used within a single object. .. versionadded:: 1.0a3 """ factory = GlobalObject( title=u'The class object that will be created.', required=True, ) pass_external_object_to_factory = Bool( title=(u"Pass the external object to the factory."), description=( u"If true (*not* the default), then, the factory will recieve " u"one argument, the anonymous external data. " u'Otherwise, it gets no arguments.'), default=False, required=False, ) trusted = Bool( title= u"Ignore any value for ``__external_can_create__`` on the factory.", required=False, default=False, ) title = MessageID( title=u"Title", description=u"Provides a title for the object.", required=False, ) description = MessageID( title=u"Description", description=u"Provides a description for the object.", required=False)
class INaayaRstkMethodDirective(Interface): """ Register a RSTK method """ handler = GlobalObject( title=_("Implementation of the method"), required=True, ) name = TextLine( title=u"Name of method (defaults to __name__ attribute of handler)", required=False, ) context = Bool( title=u"Send context as first argument", required=False, ) bundle = TextLine( title=u"Bundle to register the method (default 'Naaya')", required=False, ) getattrPatch = Bool( title=u"Backwards-compatibility patch for old getattr-style access", required=False, )
class IResourceDirective(Interface): interface = \ GlobalObject(title=u"The marker interface to use for this resource.", required=True, ) member = \ GlobalObject(title=u"The member resource class for this resource.", required=True, ) entity = \ GlobalObject(title=u"The entity class associated with the member " "resource.", required=True, ) collection = \ GlobalObject(title=u"The collection resource class for the member " "resource. If this is not specified, a dynamic " "default class is created using the values of " "`collection_root_name` and `collection_title` " "as root name and title, respectively.", required=False, ) collection_root_name = \ TextLine(title=u"The name for the root collection (used as URL path " "to the root collection inside the service). Defaults " "to the root_name attribute of the collection class.", required=False, ) collection_title = \ TextLine(title=u"The name for the root collection (used as URL path " "to the root collection inside the service). Defaults " "to the root_name attribute of the collection class.", required=False, ) repository = \ TextLine(title=u"The name of the repository that should be used for " "this resource. Defaults to 'MEMORY', the built-in " "in-memory repository (i.e., no persistence); see " "the IRepositoryDirective for other possible values.", required=False) expose = \ Bool(title=u"Flag indicating if this collection should be exposed in " "the service.", default=True, required=False, )
class IClassObjectFactoryDirective(interface.Interface): """ Defines the ``ext:classObjectFactory`` directive. This directive registers a single :class:`nti.externalization.interfaces.IClassObjectFactory`. The factory will be registered for a class object. """ factory = GlobalObject( title=u'The class object that will be created.', description= u"This must define the ``__external_can_create__`` attribute to be true.", required=True) name = PythonIdentifier( title=u"The name for the factory.", description= (u"If not given, the ``__external_class_name__`` of the class will be used. " u"If that's not available, the ``__name__`` will be used."), required=False, ) trusted = Bool( title= u"Ignore any value for ``__external_can_create__`` on the factory.", required=False, default=False, ) title = MessageID( title=u"Title", description=u"Provides a title for the object.", required=False, ) description = MessageID( title=u"Description", description=u"Provides a description for the object.", required=False)
class IRepositoryDirective(Interface): name = \ TextLine(title=u"Name of this repository. Must be unique among all " "repositories. If no name is given, or the name is " "specified as 'DEFAULT', the built-in repository is " "configured with the given directive.", required=False ) aggregate_class = \ GlobalObject(title=u"A class to use as the default aggregate " "implementation for this repository.", required=False) repository_class = \ GlobalObject(title=u"A class to use as the implementation for this " "repository.", required=False) make_default = \ Bool(title=u"Indicates if this repository should be made the default " "for all resources that do not explicitly specify a " "repository. Defaults to False.", required=False )
class IRegisterClassDirective(Interface): """registerClass directive schema. Register content with Zope 2. """ class_ = GlobalObject( title=u'Instance Class', description=u'Dotted name of the class that is registered.', required=True) meta_type = ASCII( title=u'Meta Type', description=u'A human readable unique identifier for the class.', required=True) permission = Permission( title=u'Add Permission', description=u'The permission for adding objects of this class.', required=True) addview = ASCII( title=u'Add View ID', description=u'The ID of the add view used in the ZMI. Consider this ' u'required unless you know exactly what you do.', default=None, required=False) icon = ASCII(title=u'Icon ID', description=u'The ID of the icon used in the ZMI.', default=None, required=False) global_ = Bool( title=u'Global scope?', description=u'If "global" is False the class is only available in ' u'containers that explicitly allow one of its interfaces.', default=True, required=False)
class IResourceViewDirective(IViewDirective): for_ = \ Tokens(title=u"The resource classes or interfaces to set up views " "for. For each interface in the sequence, views for " "the associated member resource class (member_view), " "the associated collection resource class " "(collection_view) or both (resource_view) are" "generated.", required=True, value_type=GlobalObject()) default_content_type = \ GlobalObject(title=u"The default MIME content type to use when the " "client does not indicate a preference. Unless " "the default_response_content_type setting is " "also specified, this applies to both the " "request and the response content type.", required=False) default_response_content_type = \ GlobalObject(title=u"The default MIME content type to use for the " "response when the client does not indicate a " "preference. If this is not specified, the " "setting for default_content_type is used.", required=False) request_method = \ Tokens(title=u"One or more request methods that need to be matched.", required=True, value_type=Choice(values=tuple(RequestMethods), default=RequestMethods.GET, ), ) enable_messaging = \ Bool(title=u"Flag indicating if messaging should be enabled for " "this view (defaults to False for GET views and to " "TRUE for PUT/POST/PATCH views).", default=None, required=False, )
class ISubscriberDirective(Interface): """ Register a subscriber """ factory = GlobalObject( title=_("Subscriber factory"), description=_("A factory used to create the subscriber instance."), required=False, ) handler = GlobalObject( title=_("Handler"), description=_("A callable object that handles events."), required=False, ) provides = GlobalInterface( title=_("Interface the component provides"), description=_("This attribute specifies the interface the adapter" " instance must provide."), required=False, ) for_ = Tokens( title=_("Interfaces or classes that this subscriber depends on"), description=_("This should be a list of interfaces or classes"), required=False, value_type=GlobalObject(missing_value=object(), ), ) permission = Permission( title=_("Permission"), description=_("This subscriber is only available, if the" " principal has this permission."), required=False, ) trusted = Bool( title=_("Trusted"), description=_("""Make the subscriber a trusted subscriber Trusted subscribers have unfettered access to the objects they adapt. If asked to adapt security-proxied objects, then, rather than getting an unproxied subscriber of security-proxied objects, you get a security-proxied subscriber of unproxied objects. """), required=False, default=False, ) locate = Bool( title=_("Locate"), description=_("""Make the subscriber a locatable subscriber Located subscribers should be used if a non-public permission is used. """), required=False, default=False, )
class IAdapterDirective(Interface): """ Register an adapter """ factory = Tokens(title=_("Adapter factory/factories"), description=_( "A list of factories (usually just one) that create" " the adapter instance."), required=True, value_type=GlobalObject()) provides = GlobalInterface( title=_("Interface the component provides"), description=_("This attribute specifies the interface the adapter" " instance must provide."), required=False, ) for_ = Tokens( title=_("Specifications to be adapted"), description=_("This should be a list of interfaces or classes"), required=False, value_type=GlobalObject(missing_value=object(), ), ) permission = Permission( title=_("Permission"), description=_("This adapter is only available, if the principal" " has this permission."), required=False, ) name = TextLine( title=_("Name"), description=_("Adapters can have names.\n\n" "This attribute allows you to specify the name for" " this adapter."), required=False, ) trusted = Bool( title=_("Trusted"), description=_("""Make the adapter a trusted adapter Trusted adapters have unfettered access to the objects they adapt. If asked to adapt security-proxied objects, then, rather than getting an unproxied adapter of security-proxied objects, you get a security-proxied adapter of unproxied objects. """), required=False, default=False, ) locate = Bool( title=_("Locate"), description=_("""Make the adapter a locatable adapter Located adapter should be used if a non-public permission is used. """), required=False, default=False, )
class IAutoPackageExternalizationDirective(interface.Interface): """ Defines the ``ext:registerAutoPackageIO`` directive. This directive combines the effects of `IRegisterInternalizationMimeFactoriesDirective` with that of :mod:`.autopackage`, removing all need to repeat root interfaces and module names. After this directive is complete, a new class that descends from :class:`~.AutoPackageSearchingScopedInterfaceObjectIO` will be registered as the :class:`~nti.externalization.interfaces.IInternalObjectIO` adapter for all of the *root_interface* objects, and the *modules* (or *factory_modules*) will be searched for object factories via `IRegisterInternalizationMimeFactoriesDirective`. .. versionchanged:: 1.0 Add the *register_legacy_search_module* keyword argument, defaulting to False. Previously legacy search modules would always be registered, but now you must explicitly ask for it. """ root_interfaces = Tokens( title=u"The root interfaces defined by the package.", value_type=GlobalInterface(), required=True) modules = Tokens( title= u"Module names that contain the implementations of the root_interfaces.", value_type=GlobalObject(), required=True) factory_modules = Tokens( title= u"If given, module names that should be searched for internalization factories.", description=( u"If not given, all *modules* will be examined. If given, " u"**only** these modules will be searched."), value_type=GlobalObject(), required=False) iobase = GlobalObject( title=(u"If given, a base class that will be used. " u"You can customize aspects of externalization that way."), description=( u"This class should descend from `object`, and it should implement " u"the extension methods documented to customize " u"`.AutoPackageSearchingScopedInterfaceObjectIO`."), required=False) register_legacy_search_module = Bool( title=(u"Register found factories by their class name."), description= (u"If true (*not* the default), then, in addition to registering " u"factories by their mime type, also register them all by their class name. " u"This is not recommended; currently no conflicts are caught and the order " u"is ill-defined. " u"See https://github.com/NextThought/nti.externalization/issues/33"), default=False, required=False, )