Back to index

plone3  3.1.7
interfaces.py
Go to the documentation of this file.
00001 from zope.interface import implements, Interface, Attribute
00002 from zope.interface.common.sequence import IReadSequence
00003 
00004 class IField(Interface):
00005     """A Field: a behavioral object associated to a context and a
00006     value"""
00007 
00008 
00009 try:
00010     from Products.Archetypes.interfaces import IATField
00011     class IATField(IField, IATField):
00012         """ at specific field interface """
00013 except ImportError:
00014     pass
00015 
00016 
00017 class IFieldValue(Interface):
00018     """ a value derived from the context. could be anything """
00019 
00020 class IFieldValueSetter(Interface):
00021     """ stores a value derived from the context. """
00022 
00023 class IFieldEvent(Interface):
00024     """ something has happened involving a field """
00025     value = Attribute("the value to render forth")
00026     instance = Attribute("the context object")
00027     field = Attribute("the field object")
00028     kwargs = Attribute("AT compatibility cruft")
00029 
00030     def __init__(field_, instance, **kwargs):
00031         """everything needed to make AT rendering go"""
00032 
00033 class IFieldRenderEvent(IFieldEvent):
00034     """ an container to fetch a value for a field """
00035     
00036 class IFieldStorageEvent(IFieldEvent):
00037     """ an container to store a value for a field """
00038 
00039 class ITxtFilter(Interface):
00040     """Abstract Base for filters.
00041 
00042     Filters happen during object access (rendering for example) and
00043     include the context the object is being run in.
00044     """
00045     name = Attribute('name for this filter')
00046 
00047     def __init__(field, context, event):
00048         """to initialize.
00049         """
00050 
00051     def __call__():
00052         """execute filter. must be a callable.
00053         """
00054 
00055 class ITxtFilterList(IReadSequence):
00056     """list of txtfilter names to apply"""
00057 
00058 ## events and exceptions ##
00059 
00060 class FieldEvent(object):
00061     implements(IFieldEvent)
00062     value=None    
00063     def __init__(self, field_, instance, **kwargs):
00064         self.field = field_
00065         self.instance = instance
00066         self.kwargs = kwargs
00067     
00068 class FieldStorageEvent(FieldEvent):
00069     implements(IFieldStorageEvent)
00070     def __init__(self, field_, instance, value, **kwargs):
00071         super(FieldStorageEvent, self).__init__(field_, instance, **kwargs)
00072         self.value = value
00073 
00074 class FieldRenderEvent(FieldEvent):
00075     implements(IFieldRenderEvent)
00076 
00077 class EndFiltrationException(Exception):
00078     """raise to stop continuation of txtfiltering"""