class IAuditableActionPerformedEvent(Interface): """An event for signaling auditable actions.""" object = Attribute("The subject of the event.") request = Attribute("The current request.") action = Attribute("A title for the performed action.") note = Attribute("Additional information for the action.")
class ILockSession(Interface): locker = Attribute('locker', """Description of the locker""") locks = Attribute('locks', """Dict of the locks""") def start_session(self, locker): """ Provide information for session :type locker: dict :param locker: information about Locker :return None """ def close_session(self): """ Close the session """ def acquire_lock(self, object_id): """ Acquire lock for session lifetime :param object_id: :return: """ def release_lock(self, object_id): """
class IStoreDirectoryRecord(Interface): """ Directory record object A record identifies a "user" in the system. """ uid = Attribute("The record UID: C{str}") shortNames = Attribute("Short names of the record: C{tuple}") fullName = Attribute( "Full name for the entity associated with the record: C{str}") displayName = Attribute( "Display name for entity associated with the record: C{str}") def serverURI(): #@NoSelf """ Return the URI for the record's server "pod". @return: a URI. @rtype: C{str} """ def server(): #@NoSelf """ Return the L{txdav.caldav.datastore.scheduling.localservers.Server} for the record's server "pod". @return: a pod server record. @rtype: L{txdav.caldav.datastore.scheduling.localservers.Server} """ def thisServer(): #@NoSelf """
class IUtilityRegistration(IRegistration): """Information about the registration of a utility """ factory = Attribute("The factory used to create the utility. Optional.") component = Attribute("The object registered") provided = Attribute("The interface provided by the component")
class IPluginTask(Interface): """A plugin task that can run on stoq server""" name = Attribute('name') handle_actions = Attribute('handle_actions') def start(**kwargs): """Called to start the task.
class IHandlerRegistration(IRegistration): handler = Attribute("An object called used to handle an event") required = Attribute("""The handled interfaces This is a sequence of interfaces handled by the registered handler. The handler will be caled with a sequence of objects, as positional arguments, that provide these interfaces. """)
class ISpecification(Interface): """Object Behavioral specifications""" def extends(other, strict=True): """Test whether a specification extends another The specification extends other if it has other as a base interface or if one of it's bases extends other. If strict is false, then the specification extends itself. """ def isOrExtends(other): """Test whether the specification is or extends another """ def weakref(callback=None): """Return a weakref to the specification This method is, regrettably, needed to allow weakrefs to be computed to security-proxied specifications. While the zope.interface package does not require zope.security or zope.proxy, it has to be able to coexist with it. """ __bases__ = Attribute("""Base specifications A tuple if specifications from which this specification is directly derived. """) __sro__ = Attribute("""Specification-resolution order A tuple of the specification and all of it's ancestor specifications from most specific to least specific. (This is similar to the method-resolution order for new-style classes.) """) __iro__ = Attribute("""Interface-resolution order A tuple of the of the specification's ancestor interfaces from most specific to least specific. The specification itself is included if it is an interface. (This is similar to the method-resolution order for new-style classes.) """) def get(name, default=None): """Look up the description for a name
class IRegistration(Interface): """A registration-information object """ registry = Attribute("The registry having the registration") name = Attribute("The registration name") info = Attribute("""Information about the registration This is information deemed useful to people browsing the configuration of a system. It could, for example, include commentary or information about the source of the configuration. """)
class IServiceProtocol(Interface): """Interface for Service objects to make requests.""" dereferred = Attribute("Chain of actions that result in protocol invocation") def request(*args): """Setup a request for data.
class _IBaseAdapterRegistration(IRegistration): """Information about the registration of an adapter """ factory = Attribute("The factory used to create adapters") required = Attribute("""The adapted interfaces This is a sequence of interfaces adapters by the registered factory. The factory will be caled with a sequence of objects, as positional arguments, that provide these interfaces. """) provided = Attribute("""The interface provided by the adapters. This interface is implemented by the factory """)
class IObjectEvent(Interface): """An event related to an object. The object that generated this event is not necessarily the object refered to by location. """ object = Attribute("The subject of the event.")
class IXMPPUser(Interface): """ An interface for users """ jid = Attribute("""The JID of the user""") def logout(): """
class IPlugin(Interface): name = Attribute('name') def activate(): """Called everytime the plugins gets activated This is where the init plugin logic should be, like events connection and so on. """ pass def get_migration(): """Get the database migration for the plugin :returns: a :class:`stoqlib.database.migration.PluginSchemaMigration` """ pass def get_tables(): """Returns a C{list} of domain classes This should return a C{list} of tuples, each one containing the domain path as the first item, and a list of classes as the second. e.g. A 'from a.b import C, D' should be translated into the C{tuple} ('a.b', ['C', 'D']). @note: this information is used for database synchronization :returns: a C{list} of C{tuple} containing domain info """ pass def get_server_tasks(): """Get a list of tasks that the server will be responsible to run A task is a object implementing :class:`.IPluginTask`. :returns: a list of tasks """ pass def get_dbadmin_commands(): """Returns a list of available commands for dbadmin :returns: a C{list} of available commands """ pass def handle_dbadmin_command(command, options, args): """Handle a dbadmin command :param command: the command string :param options: extra optparser options :param args: a list of C{args} """ pass
class IReceivingInitializer(ijabber.IInitializer): """ Interface for XML stream initializers for the initiating entity. """ xmlstream = Attribute("""The associated XML stream""") required = Attribute("""Whether this initialization step is required""") def feature(): """ return a domish element that represents the feature, or None """ def initialize(): """ Initiate the initialization step. Unlike IInitializingInitializer this should not return a deferred. All initialize should do is add some observers and see what the client does next. """ def deinitialize(): """
class IElement(Interface): """Objects that have basic documentation and tagged values. """ __name__ = Attribute('__name__', 'The object name') __doc__ = Attribute('__doc__', 'The object doc string') def getTaggedValue(tag): """Returns the value associated with `tag`. Raise a `KeyError` of the tag isn't set. """ def queryTaggedValue(tag, default=None): """Returns the value associated with `tag`. Return the default value of the tag isn't set. """ def getTaggedValueTags(): """Returns a list of all tags.""" def setTaggedValue(tag, value): """Associates `value` with `key`."""
class FooInterface(Interface): """ This is an Abstract Base Class """ foobar = Attribute("fuzzed over beyond all recognition") def aMethod(foo, bar, bingo): """ This is aMethod """ def anotherMethod(foo=6, bar="where you get sloshed", bingo=(1,3,)): """ This is anotherMethod """ def wammy(zip, *argues): """ yadda yadda """ def useless(**keywords): """ useless code is fun! """
class IBaseReporter(Interface): """base class for reporters symbols: show short symbolic names for messages. """ extension = Attribute('') def handle_message(msg): """Handle a new message triggered on the current file.""" def set_output(output=None): """set output stream""" def writeln(string=''): """write a line in the output buffer""" def display_reports(layout): """display results encapsulated in the layout tree""" def _display(layout): """display the layout""" def display_messages(layout): """Hook for displaying the messages of the reporter This will be called whenever the underlying messages needs to be displayed. For some reporters, it probably doesn't make sense to display messages as soon as they are available, so some mechanism of storing them could be used. This method can be implemented to display them after they've been aggregated. """ def on_set_current_module(module, filepath): """Hook called when a module starts to be analysed.""" def on_close(stats, previous_stats): """Hook called when a module finished analyzing."""
class ISASLServerMechanism(Interface): """ The server-side of ISASLMechanism. Could perhaps be integrated into twisted.words.protocols.jabber.sasl_mechanisms.ISSASLMechanism """ portal = Attribute("""A twisted.cred portal to authenticate through""") def getInitialChallenge(): """ Create an initial challenge. Used by e.g. DIGEST-MD5 """ def parseInitialResponse(response): """ Parse the initial resonse from the client, if any and return a deferred. The deferred's callback returns either an instance of IXMPPUser or a string that should be used as a subsequent challenge to be sent to the client. Raises SASLAuthError as errback on failure """ def parseResponse(response): """
class IInterfaceDeclaration(Interface): """ Declare and check the interfaces of objects. The functions defined in this interface are used to declare the interfaces that objects provide and to query the interfaces that have been declared. Interfaces can be declared for objects in two ways: - Interfaces are declared for instances of the object's class - Interfaces are declared for the object directly. The interfaces declared for an object are, therefore, the union of interfaces declared for the object directly and the interfaces declared for instances of the object's class. Note that we say that a class implements the interfaces provided by it's instances. An instance can also provide interfaces directly. The interfaces provided by an object are the union of the interfaces provided directly and the interfaces implemented by the class. This interface is implemented by :mod:`zope.interface`. """ ### # Defining interfaces ### Interface = Attribute("The base class used to create new interfaces") def taggedValue(key, value): """ Attach a tagged value to an interface while defining the interface. This is a way of executing :meth:`IElement.setTaggedValue` from the definition of the interface. For example:: class IFoo(Interface): taggedValue('key', 'value') .. seealso:: `zope.interface.taggedValue` """ def invariant(checker_function): """ Attach an invariant checker function to an interface while defining it. Invariants can later be validated against particular implementations by calling :meth:`IInterface.validateInvariants`. For example:: def check_range(ob): if ob.max < ob.min: raise ValueError("max value is less than min value") class IRange(Interface): min = Attribute("The min value") max = Attribute("The max value") invariant(check_range) .. seealso:: `zope.interface.invariant` """ def interfacemethod(method): """ A decorator that transforms a method specification into an implementation method. This is used to override methods of ``Interface`` or provide new methods. Definitions using this decorator will not appear in :meth:`IInterface.names()`. It is possible to have an implementation method and a method specification of the same name. For example:: class IRange(Interface): @interfacemethod def __adapt__(self, obj): if isinstance(obj, range): # Return the builtin ``range`` as-is return obj return super(type(IRange), self).__adapt__(obj) You can use ``super`` to call the parent class functionality. Note that the zero-argument version (``super().__adapt__``) works on Python 3.6 and above, but prior to that the two-argument version must be used, and the class must be explicitly passed as the first argument. .. versionadded:: 5.1.0 .. seealso:: `zope.interface.interfacemethod` """ ### # Querying interfaces ### def providedBy(ob): """ Return the interfaces provided by an object. This is the union of the interfaces directly provided by an object and interfaces implemented by it's class. The value returned is an `IDeclaration`. .. seealso:: `zope.interface.providedBy` """ def implementedBy(class_): """ Return the interfaces implemented for a class's instances. The value returned is an `IDeclaration`. .. seealso:: `zope.interface.implementedBy` """ ### # Declaring interfaces ### def classImplements(class_, *interfaces): """ Declare additional interfaces implemented for instances of a class. The arguments after the class are one or more interfaces or interface specifications (`IDeclaration` objects). The interfaces given (including the interfaces in the specifications) are added to any interfaces previously declared. Consider the following example:: class C(A, B): ... classImplements(C, I1, I2) Instances of ``C`` provide ``I1``, ``I2``, and whatever interfaces instances of ``A`` and ``B`` provide. This is equivalent to:: @implementer(I1, I2) class C(A, B): pass .. seealso:: `zope.interface.classImplements` .. seealso:: `zope.interface.implementer` """ def classImplementsFirst(cls, interface): """ See :func:`zope.interface.classImplementsFirst`. """ def implementer(*interfaces): """ Create a decorator for declaring interfaces implemented by a factory. A callable is returned that makes an implements declaration on objects passed to it. .. seealso:: :meth:`classImplements` """ def classImplementsOnly(class_, *interfaces): """ Declare the only interfaces implemented by instances of a class. The arguments after the class are one or more interfaces or interface specifications (`IDeclaration` objects). The interfaces given (including the interfaces in the specifications) replace any previous declarations. Consider the following example:: class C(A, B): ... classImplements(C, IA, IB. IC) classImplementsOnly(C. I1, I2) Instances of ``C`` provide only ``I1``, ``I2``, and regardless of whatever interfaces instances of ``A`` and ``B`` implement. .. seealso:: `zope.interface.classImplementsOnly` """ def implementer_only(*interfaces): """ Create a decorator for declaring the only interfaces implemented. A callable is returned that makes an implements declaration on objects passed to it. .. seealso:: `zope.interface.implementer_only` """ def directlyProvidedBy(object): """ Return the interfaces directly provided by the given object. The value returned is an `IDeclaration`. .. seealso:: `zope.interface.directlyProvidedBy` """ def directlyProvides(object, *interfaces): """ Declare interfaces declared directly for an object. The arguments after the object are one or more interfaces or interface specifications (`IDeclaration` objects). .. caution:: The interfaces given (including the interfaces in the specifications) *replace* interfaces previously declared for the object. See :meth:`alsoProvides` to add additional interfaces. Consider the following example:: class C(A, B): ... ob = C() directlyProvides(ob, I1, I2) The object, ``ob`` provides ``I1``, ``I2``, and whatever interfaces instances have been declared for instances of ``C``. To remove directly provided interfaces, use `directlyProvidedBy` and subtract the unwanted interfaces. For example:: directlyProvides(ob, directlyProvidedBy(ob)-I2) removes I2 from the interfaces directly provided by ``ob``. The object, ``ob`` no longer directly provides ``I2``, although it might still provide ``I2`` if it's class implements ``I2``. To add directly provided interfaces, use `directlyProvidedBy` and include additional interfaces. For example:: directlyProvides(ob, directlyProvidedBy(ob), I2) adds I2 to the interfaces directly provided by ob. .. seealso:: `zope.interface.directlyProvides` """ def alsoProvides(object, *interfaces): """ Declare additional interfaces directly for an object. For example:: alsoProvides(ob, I1) is equivalent to:: directlyProvides(ob, directlyProvidedBy(ob), I1) .. seealso:: `zope.interface.alsoProvides` """ def noLongerProvides(object, interface): """ Remove an interface from the list of an object's directly provided interfaces. For example:: noLongerProvides(ob, I1) is equivalent to:: directlyProvides(ob, directlyProvidedBy(ob) - I1) with the exception that if ``I1`` is an interface that is provided by ``ob`` through the class's implementation, `ValueError` is raised. .. seealso:: `zope.interface.noLongerProvides` """ def implements(*interfaces): """ Declare interfaces implemented by instances of a class. .. deprecated:: 5.0 This only works for Python 2. The `implementer` decorator is preferred for all versions. This function is called in a class definition (Python 2.x only). The arguments are one or more interfaces or interface specifications (`IDeclaration` objects). The interfaces given (including the interfaces in the specifications) are added to any interfaces previously declared. Previous declarations include declarations for base classes unless implementsOnly was used. This function is provided for convenience. It provides a more convenient way to call `classImplements`. For example:: implements(I1) is equivalent to calling:: classImplements(C, I1) after the class has been created. Consider the following example (Python 2.x only):: class C(A, B): implements(I1, I2) Instances of ``C`` implement ``I1``, ``I2``, and whatever interfaces instances of ``A`` and ``B`` implement. """ def implementsOnly(*interfaces): """ Declare the only interfaces implemented by instances of a class. .. deprecated:: 5.0 This only works for Python 2. The `implementer_only` decorator is preferred for all versions. This function is called in a class definition (Python 2.x only). The arguments are one or more interfaces or interface specifications (`IDeclaration` objects). Previous declarations including declarations for base classes are overridden. This function is provided for convenience. It provides a more convenient way to call `classImplementsOnly`. For example:: implementsOnly(I1) is equivalent to calling:: classImplementsOnly(I1) after the class has been created. Consider the following example (Python 2.x only):: class C(A, B): implementsOnly(I1, I2) Instances of ``C`` implement ``I1``, ``I2``, regardless of what instances of ``A`` and ``B`` implement. """ def classProvides(*interfaces): """ Declare interfaces provided directly by a class. .. deprecated:: 5.0 This only works for Python 2. The `provider` decorator is preferred for all versions. This function is called in a class definition. The arguments are one or more interfaces or interface specifications (`IDeclaration` objects). The given interfaces (including the interfaces in the specifications) are used to create the class's direct-object interface specification. An error will be raised if the module class has an direct interface specification. In other words, it is an error to call this function more than once in a class definition. Note that the given interfaces have nothing to do with the interfaces implemented by instances of the class. This function is provided for convenience. It provides a more convenient way to call `directlyProvides` for a class. For example:: classProvides(I1) is equivalent to calling:: directlyProvides(theclass, I1) after the class has been created. """ def provider(*interfaces): """ A class decorator version of `classProvides`. .. seealso:: `zope.interface.provider` """ def moduleProvides(*interfaces): """ Declare interfaces provided by a module. This function is used in a module definition. The arguments are one or more interfaces or interface specifications (`IDeclaration` objects). The given interfaces (including the interfaces in the specifications) are used to create the module's direct-object interface specification. An error will be raised if the module already has an interface specification. In other words, it is an error to call this function more than once in a module definition. This function is provided for convenience. It provides a more convenient way to call `directlyProvides` for a module. For example:: moduleImplements(I1) is equivalent to:: directlyProvides(sys.modules[__name__], I1) .. seealso:: `zope.interface.moduleProvides` """ def Declaration(*interfaces): """
class IMailingList(Interface): """ A de facto interface for some MailBoxer-y things, includes the basic public features, minus those that are useful primarily for smtp2zope.py """ title = TextLine( title=_(u"Title"), description=_(u'mailing_list_title', u""), required=True, ) description = Text(title=_(u"Description"), description=_(u"A description of the mailing list."), default=u'', required=False) mailto = ASCII( title=_(u"List Address"), description=_(u"Main address for the mailing list."), required=True, constraint=check_mailto, ) manager_email = Attribute( "The published address which general inquiries about the " "list will be sent to. Usually [email protected].") managers = Tuple( title=_(u"Managers"), description=_(u"The people who maintain the list. Managers can " "edit list settings and can edit the list of allowed " "senders / subscribers. Managers receive moderation " "requests, general inquiries and any bounced mail."), default=(), required=True, value_type=TextLine(title=_(u"Manager"), ), ) list_type = Choice( title=_(u"List Type"), description=_(u"The policy that defines the behavior of the list."), vocabulary='List Types', default=PublicListTypeDefinition, required=True) archived = Choice( title=_(u"Archival method"), description=_(u"When archiving is enabled, all messages sent to " "the list will be saved on the server. You may " "choose whether to archive just the message text, " "or include attachments."), vocabulary="Archive Options", default=0, required=True, ) private_archives = Choice( title=_(u"Privacy"), description=_(u"You can choose whether to allow list non-members " "to view the list's archives, or restrict the archives " "to logged-in subscribers."), vocabulary="Archive Privacy Options", default=False, required=True, ) # These methods really belong in an adapter(s), but because we are using # MailBoxer they are part of the content object. def addMail(message_string): """ Parses a mail message into a string and stores it in the archive as an IMailMessage. Returns the resulting mail message object. """ def checkMail(request): """ Extracts a message from an HTTP request checks its validity. Returns None if the mail passes validation, otherwise it returns a string describing the error. Expects a request variable 'Mail' containing the mail message with headers. """ def requestMail(request): """ Extracts an (un)subscribe request message from an HTTP request and processes it. Expects a request variable 'Mail' containing the mail message with headers. """ def processMail(request): """ Extracts a message from an HTTP request and processes it for the mailing list. Checks the validity of the sender and whether moderation is needed. Expects a request variable 'Mail' containing the mail message with headers """ def moderateMail(request): """ Processes an HTTP request for information on what to do with a specific mail message in the moderation queue. Expects the request to contain an 'action' ('approve' or 'discard'), a 'pin' used to authenticate the moderator, and an 'mid' which is the id of the mail object in the moderation queue. Expects a request variable 'Mail' containing the mail message with headers """ def bounceMail(request): """ Extracts a bounce message from an HTTP request and processes it to note any subscriber addresses that resulted in bounces. """ def resetBounces(addresses): """ Remove specified email addresses from the list of recipients with bounced messages. """ def sendCommandRequestMail(address, subject, body): """
class IComponentLookup(Interface): """Component Manager for a Site This object manages the components registered at a particular site. The definition of a site is intentionally vague. """ adapters = Attribute("Adapter Registry to manage all registered adapters.") utilities = Attribute( "Adapter Registry to manage all registered utilities.") def queryAdapter(object, interface, name=_BLANK, default=None): """Look for a named adapter to an interface for an object If a matching adapter cannot be found, returns the default. """ def getAdapter(object, interface, name=_BLANK): """Look for a named adapter to an interface for an object If a matching adapter cannot be found, a ComponentLookupError is raised. """ def queryMultiAdapter(objects, interface, name=_BLANK, default=None): """Look for a multi-adapter to an interface for multiple objects If a matching adapter cannot be found, returns the default. """ def getMultiAdapter(objects, interface, name=_BLANK): """Look for a multi-adapter to an interface for multiple objects If a matching adapter cannot be found, a ComponentLookupError is raised. """ def getAdapters(objects, provided): """Look for all matching adapters to a provided interface for objects Return an iterable of name-adapter pairs for adapters that provide the given interface. """ def subscribers(objects, provided): """Get subscribers Subscribers are returned that provide the provided interface and that depend on and are comuted from the sequence of required objects. """ def handle(*objects): """Call handlers for the given objects Handlers registered for the given objects are called. """ def queryUtility(interface, name='', default=None): """Look up a utility that provides an interface. If one is not found, returns default. """ def getUtilitiesFor(interface): """Look up the registered utilities that provide an interface. Returns an iterable of name-utility pairs. """ def getAllUtilitiesRegisteredFor(interface): """Return all registered utilities for an interface
class IElement(Interface): """ Objects that have basic documentation and tagged values. Known derivatives include :class:`IAttribute` and its derivative :class:`IMethod`; these have no notion of inheritance. :class:`IInterface` is also a derivative, and it does have a notion of inheritance, expressed through its ``__bases__`` and ordered in its ``__iro__`` (both defined by :class:`ISpecification`). """ # Note that defining __doc__ as an Attribute hides the docstring # from introspection. When changing it, also change it in the Sphinx # ReST files. __name__ = Attribute('__name__', 'The object name') __doc__ = Attribute('__doc__', 'The object doc string') ### # Tagged values. # # Direct values are established in this instance. Others may be # inherited. Although ``IElement`` itself doesn't have a notion of # inheritance, ``IInterface`` *does*. It might have been better to # make ``IInterface`` define new methods # ``getIndirectTaggedValue``, etc, to include inheritance instead # of overriding ``getTaggedValue`` to do that, but that ship has sailed. # So to keep things nice and symmetric, we define the ``Direct`` methods here. ### def getTaggedValue(tag): """Returns the value associated with *tag*. Raise a `KeyError` if the tag isn't set. If the object has a notion of inheritance, this searches through the inheritance hierarchy and returns the nearest result. If there is no such notion, this looks only at this object. .. versionchanged:: 4.7.0 This method should respect inheritance if present. """ def queryTaggedValue(tag, default=None): """ As for `getTaggedValue`, but instead of raising a `KeyError`, returns *default*. .. versionchanged:: 4.7.0 This method should respect inheritance if present. """ def getTaggedValueTags(): """ Returns a collection of all tags in no particular order. If the object has a notion of inheritance, this includes all the inherited tagged values. If there is no such notion, this looks only at this object. .. versionchanged:: 4.7.0 This method should respect inheritance if present. """ def setTaggedValue(tag, value): """ Associates *value* with *key* directly in this object. """ def getDirectTaggedValue(tag): """ As for `getTaggedValue`, but never includes inheritance. .. versionadded:: 5.0.0 """ def queryDirectTaggedValue(tag, default=None): """ As for `queryTaggedValue`, but never includes inheritance. .. versionadded:: 5.0.0 """ def getDirectTaggedValueTags(): """
class IAttribute(IElement): """Attribute descriptors""" interface = Attribute( 'interface', 'Stores the interface instance in which the ' 'attribute is located.')
class IInterface(ISpecification, IElement): """Interface objects Interface objects describe the behavior of an object by containing useful information about the object. This information includes: o Prose documentation about the object. In Python terms, this is called the "doc string" of the interface. In this element, you describe how the object works in prose language and any other useful information about the object. o Descriptions of attributes. Attribute descriptions include the name of the attribute and prose documentation describing the attributes usage. o Descriptions of methods. Method descriptions can include: - Prose "doc string" documentation about the method and its usage. - A description of the methods arguments; how many arguments are expected, optional arguments and their default values, the position or arguments in the signature, whether the method accepts arbitrary arguments and whether the method accepts arbitrary keyword arguments. o Optional tagged data. Interface objects (and their attributes and methods) can have optional, application specific tagged data associated with them. Examples uses for this are examples, security assertions, pre/post conditions, and other possible information you may want to associate with an Interface or its attributes. Not all of this information is mandatory. For example, you may only want the methods of your interface to have prose documentation and not describe the arguments of the method in exact detail. Interface objects are flexible and let you give or take any of these components. Interfaces are created with the Python class statement using either Interface.Interface or another interface, as in:: from zope.interface import Interface class IMyInterface(Interface): '''Interface documentation''' def meth(arg1, arg2): '''Documentation for meth''' # Note that there is no self argument class IMySubInterface(IMyInterface): '''Interface documentation''' def meth2(): '''Documentation for meth2''' You use interfaces in two ways: o You assert that your object implement the interfaces. There are several ways that you can assert that an object implements an interface: 1. Call zope.interface.implements in your class definition. 2. Call zope.interfaces.directlyProvides on your object. 3. Call 'zope.interface.classImplements' to assert that instances of a class implement an interface. For example:: from zope.interface import classImplements classImplements(some_class, some_interface) This approach is useful when it is not an option to modify the class source. Note that this doesn't affect what the class itself implements, but only what its instances implement. o You query interface meta-data. See the IInterface methods and attributes for details. """ def names(all=False): """Get the interface attribute names Return a sequence of the names of the attributes, including methods, included in the interface definition. Normally, only directly defined attributes are included. If a true positional or keyword argument is given, then attributes defined by base classes will be included. """ def namesAndDescriptions(all=False): """Get the interface attribute names and descriptions Return a sequence of the names and descriptions of the attributes, including methods, as name-value pairs, included in the interface definition. Normally, only directly defined attributes are included. If a true positional or keyword argument is given, then attributes defined by base classes will be included. """ def __getitem__(name): """Get the description for a name If the named attribute is not defined, a KeyError is raised. """ def direct(name): """Get the description for the name if it was defined by the interface If the interface doesn't define the name, returns None. """ def validateInvariants(obj, errors=None): """Validate invariants Validate object to defined invariants. If errors is None, raises first Invalid error; if errors is a list, appends all errors to list, then raises Invalid with the errors as the first element of the "args" tuple.""" def __contains__(name): """Test whether the name is defined by the interface""" def __iter__(): """Return an iterator over the names defined by the interface The names iterated include all of the names defined by the interface directly and indirectly by base interfaces. """ __module__ = Attribute("""The name of the module defining the interface""")
class ICalendarStoreDirectoryRecord(IStoreDirectoryRecord): """ Record object for calendar users. A record identifies a "user" in the system. """ calendarUserAddresses = Attribute( "Calendar users address for entity associated with the record: C{frozenset}" ) def canonicalCalendarUserAddress(): #@NoSelf """ The canonical calendar user address to use for this record. @return: the canonical calendar user address. @rtype: C{str} """ def calendarsEnabled(): #@NoSelf """ Indicates whether the record enabled for using the calendar service. @return: C{True} if enabled for this service. @rtype: C{bool} """ def enabledAsOrganizer(): #@NoSelf """ Indicates that the record is allowed to be the Organizer in calendar data. @return: C{True} if allowed to be the Organizer. @rtype: C{bool} """ def getCUType(): #@NoSelf """ Indicates the calendar user type for this record. It is the RFC 5545 CUTYPE value. @return: the calendar user type. @rtype: C{str} """ def canAutoSchedule(organizer): #@NoSelf """ Indicates that calendar data for this record can be automatically scheduled. @param organizer: the organizer of the scheduling message being processed @type organizer: C{str} @return: C{True} if automatically scheduled. @rtype: C{bool} """ def getAutoScheduleMode(organizer): #@NoSelf """ Indicates the mode of automatic scheduling used for this record. @param organizer: the organizer of the scheduling message being processed @type organizer: C{str} @return: C{True} if automatically scheduled. @rtype: C{bool} """ def isProxyFor(other): #@NoSelf """ Test whether the record is a calendar user proxy for the specified record. @param other: record to test @type other: L{IDirectoryRecord} @return: C{True} if it is a proxy. @rtype: C{bool} """ def proxyMode(other): #@NoSelf """ Determine the proxy mode this record has in relation to the one specified. @param other: record for the possible user proxying to this record @type other: L{CalendarDirectoryRecordMixin} """ def proxyFor(readWrite, ignoreDisabled=True): #@NoSelf """
class IBeforeStoreAuditlogEntryEvent(Interface): """ Event fired before storing an entry into the auditlog""" object = Attribute('The subject of the event.') data = Attribute('The data stored in the log')
class IPaymentOperation(Interface): """An object implementing IPaymentOperation is a 1:1 mapping to a payment method. It's responsible for the logic specific parts of a method. """ name = Attribute('name') description = Attribute('description') max_installments = Attribute('max_installments') def payment_create(payment): """This is called when a payment is created :param payment: the created payment """ def payment_delete(payment): """This is called just before a payment is deleted :param payment: the payment which is going to be deleted """ def create_transaction(): """If this payment method should create a transaction when paid :returns: True if an AccountTransaction should be created """ def selectable(method): """This is called to find out if the method should be shown in the slave list of payment methods :returns: True if it should be shown """ def creatable(method, payment_type, separate): """If it's possible to create new payments of this payment method type :param method: payment method :param payment_type: kind of payment :param separate: if it's created separately from a sale/purchase :returns: True if you can create new methods of this type """ def can_cancel(payment): """If it's possible to cancel a payment :param payment: the payment to cancel """ def can_change_due_date(payment): """If it's possible to change the due date of a payment :param payment: the payment to change due date """ def can_pay(payment): """If it's possible to pay a payable :param payment: the payment to pay """ def can_print(payment): """If it's possible to print this payment :param payment: the payment to print """ def can_set_not_paid(payment): """If it can be set as not paid once it has been paid :param payment: the payment to be set as not paid """ def print_(payment): """Prints this payment :param payment: the payment to print """ def get_constant(payment): """This should return a stoqdriver payment method constant :param payment: the payment whose method we shout return a stoqdrivers constant :returns: one :class:`PaymentMethodConstant` """ def require_person(payment_type): """If this payment requires a person to be created
class IMessageComp(Interface): """Interface for TupleComp""" comp_select_list = Attribute("""The comparisons""")
class IInvariant(Interface): foo = Attribute('foo') bar = Attribute('bar; must eval to Boolean True if foo does') invariant(ifFooThenBar)
class IGetMailHost(IRegisterable): """A utility for getting the mail host object""" mail_host = Attribute("returns the mail host")