Back to index

plone3  3.1.7
Public Member Functions | Static Public Attributes | Private Member Functions | Static Private Attributes
Archetypes.Storage.annotation.MetadataAnnotationStorage Class Reference
Inheritance diagram for Archetypes.Storage.annotation.MetadataAnnotationStorage:
Inheritance graph
[legend]
Collaboration diagram for Archetypes.Storage.annotation.MetadataAnnotationStorage:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def initializeInstance
def initializeField
def cleanupField
def cleanupInstance
def get
def set
def unset

Static Public Attributes

tuple security = ClassSecurityInfo()

Private Member Functions

def _migration
def _cleanup

Static Private Attributes

 _key = AT_MD_STORAGE
tuple __implements__ = (IStorage, ILayer,)

Detailed Description

Stores metadata as ATAnnotations on the object

Definition at line 119 of file annotation.py.


Member Function Documentation

def Archetypes.Storage.annotation.MetadataAnnotationStorage._cleanup (   self,
  name,
  instance,
  value,
  kwargs 
) [private]
Clean up data in set method

Reimplemented from Archetypes.Storage.annotation.BaseAnnotationStorage.

Definition at line 143 of file annotation.py.

00143 
00144     def _cleanup(self, name, instance, value, **kwargs):
00145         md = aq_base(instance)._md
00146         try:
00147             del md[name]
00148         except KeyError:
00149             pass

Here is the caller graph for this function:

def Archetypes.Storage.annotation.MetadataAnnotationStorage._migration (   self,
  name,
  instance,
  kwargs 
) [private]
Migrates data from the original storage

Reimplemented from Archetypes.Storage.annotation.BaseAnnotationStorage.

Definition at line 129 of file annotation.py.

00129 
00130     def _migration(self, name, instance, **kwargs):
00131         """Migrates data from the original storage
00132         """
00133         try:
00134             md = aq_base(instance)._md
00135             value = md[name]
00136         except KeyError, msg:
00137             # We are acting like an attribute, so
00138             # raise AttributeError instead of KeyError
00139             raise AttributeError(name, msg)
00140         self.set(name, instance, value, **kwargs)
00141         del md[name]
00142         return value
        

Here is the call graph for this function:

def Archetypes.Storage.annotation.MetadataAnnotationStorage.cleanupField (   self,
  instance,
  field,
  kwargs 
)

Definition at line 165 of file annotation.py.

00165 
00166     def cleanupField(self, instance, field, **kwargs):
00167         # Don't clean up the field self to avoid problems with copy/rename. The
00168         # python garbarage system will clean up if needed.
00169         pass

def Archetypes.Storage.annotation.MetadataAnnotationStorage.cleanupInstance (   self,
  instance,
  item = None,
  container = None 
)

Definition at line 171 of file annotation.py.

00171 
00172     def cleanupInstance(self, instance, item=None, container=None):
00173         # Don't clean up the instance self to avoid problems with copy/rename. The
00174         # python garbarage system will clean up if needed.
00175         pass
00176 
00177 registerStorage(MetadataAnnotationStorage)

def Archetypes.Storage.annotation.BaseAnnotationStorage.get (   self,
  name,
  instance,
  kwargs 
) [inherited]

Definition at line 66 of file annotation.py.

00066 
00067     def get(self, name, instance, **kwargs):
00068         ann = getAnnotation(instance)
00069         value = ann.getSubkey(self._key, subkey=name, default=_marker)
00070         if value is _marker:
00071             if self._migrate:
00072                 value = self._migration(name, instance, **kwargs)
00073             else:
00074                 raise AttributeError(name)
00075         return value

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 156 of file annotation.py.

00156 
00157     def initializeField(self, instance, field):
00158         # Check for already existing field to avoid  the reinitialization
00159         # (which means overwriting) of an already existing field after a
00160         # copy or rename operation
00161         ann = getAnnotation(instance)
00162         if not ann.hasSubkey(self._key, subkey=field.getName()):
00163             self.set(field.getName(), instance, field.getDefault(instance))

Here is the call graph for this function:

def Archetypes.Storage.annotation.MetadataAnnotationStorage.initializeInstance (   self,
  instance,
  item = None,
  container = None 
)

Definition at line 151 of file annotation.py.

00151 
00152     def initializeInstance(self, instance, item=None, container=None):
00153         # annotations are initialized on first access
00154         pass

def Archetypes.Storage.annotation.BaseAnnotationStorage.set (   self,
  name,
  instance,
  value,
  kwargs 
) [inherited]

Definition at line 77 of file annotation.py.

00077 
00078     def set(self, name, instance, value, **kwargs):
00079         # Remove acquisition wrappers
00080         value = aq_base(value)
00081         ann = getAnnotation(instance)
00082         ann.setSubkey(self._key, value, subkey=name)
00083         if self._migrate:
00084             self._cleanup(name, instance, value, **kwargs) 

Here is the call graph for this function:

Here is the caller graph for this function:

def Archetypes.Storage.annotation.BaseAnnotationStorage.unset (   self,
  name,
  instance,
  kwargs 
) [inherited]

Definition at line 86 of file annotation.py.

00086 
00087     def unset(self, name, instance, **kwargs):
00088         ann = getAnnotation(instance)
00089         try:
00090             ann.delSubkey(self._key, subkey=name)
00091         except KeyError:
00092             pass
00093 
00094 setSecurity(BaseAnnotationStorage)

Here is the call graph for this function:


Member Data Documentation

tuple Archetypes.Storage.annotation.MetadataAnnotationStorage.__implements__ = (IStorage, ILayer,) [static, private]

Reimplemented from Archetypes.Storage.annotation.BaseAnnotationStorage.

Definition at line 127 of file annotation.py.

Reimplemented from Archetypes.Storage.annotation.BaseAnnotationStorage.

Definition at line 123 of file annotation.py.

Reimplemented from Archetypes.Storage.annotation.BaseAnnotationStorage.

Definition at line 125 of file annotation.py.


The documentation for this class was generated from the following file: