Back to index

plone3  3.1.7
Public Member Functions | Public Attributes
Marshall.namespaces.dcns.DCAttribute Class Reference
Inheritance diagram for Marshall.namespaces.dcns.DCAttribute:
Inheritance graph
[legend]
Collaboration diagram for Marshall.namespaces.dcns.DCAttribute:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def get
def deserialize
def serialize
def processXmlValue

Public Attributes

 accessor
 mutator
 many
 process

Detailed Description

Definition at line 60 of file dcns.py.


Constructor & Destructor Documentation

def Marshall.namespaces.dcns.DCAttribute.__init__ (   self,
  name,
  accessor,
  mutator,
  many = False,
  process = () 
)

Definition at line 67 of file dcns.py.

00067 
00068                  process=()):
00069 
00070         super(DCAttribute, self).__init__(name)
00071 
00072         self.accessor = accessor
00073         self.mutator = mutator
00074         self.many = many
00075         self.process = process


Member Function Documentation

def Marshall.namespaces.dcns.DCAttribute.deserialize (   self,
  instance,
  ns_data 
)

Definition at line 91 of file dcns.py.

00091 
00092     def deserialize(self, instance, ns_data):
00093         
00094         value = ns_data.get( self.name )
00095 
00096         if not self.mutator or not value:
00097             return
00098         
00099         if self.process:
00100             for p in self.process:
00101                 value = p( value )
00102 
00103         mutator = getattr( instance, self.mutator )
00104         mutator( value )

Here is the call graph for this function:

def Marshall.namespaces.dcns.DCAttribute.get (   self,
  instance 
)

Definition at line 76 of file dcns.py.

00076 
00077     def get(self, instance):
00078         accessor = getattr( instance, self.accessor)
00079         value = accessor()
00080 
00081         if not value:
00082             return None
00083         elif not isinstance( value, (list, tuple) ):
00084             values = [value]
00085         elif self.many:
00086             values = value
00087         else:
00088             raise AssertionError("Many values on single value attr")
00089         
00090         return filter(None, values)

Here is the caller graph for this function:

def Marshall.namespaces.dcns.DCAttribute.processXmlValue (   self,
  context,
  value 
)

Definition at line 119 of file dcns.py.

00119 
00120     def processXmlValue(self, context, value):
00121         value = value and value.strip()
00122         if not value:
00123             return
00124         data = context.getDataFor( self.namespace.xmlns )
00125         
00126         if self.many:
00127             data.setdefault(self.name, []).append( value )
00128         else:
00129             data[self.name]=value
            

Here is the call graph for this function:

def Marshall.namespaces.dcns.DCAttribute.serialize (   self,
  dom,
  parent_node,
  instance 
)

Definition at line 105 of file dcns.py.

00105 
00106     def serialize(self, dom, parent_node, instance):
00107         values = self.get( instance )
00108         if not values:
00109             return False
00110             
00111         for value in values:
00112             elname = "%s:%s"%(self.namespace.prefix, self.name)
00113             node = dom.createElementNS( DublinCore.xmlns, elname)
00114             value_node = dom.createTextNode( str( value ) )
00115             node.appendChild( value_node )
00116             node.normalize()
00117             parent_node.appendChild( node )
00118         return True


Member Data Documentation

Definition at line 71 of file dcns.py.

Definition at line 73 of file dcns.py.

Definition at line 72 of file dcns.py.

Definition at line 74 of file dcns.py.


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