Back to index

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

List of all members.

Public Member Functions

def get
def serialize
def processXmlValue
def deserialize
def resolveReferences
def isReference

Public Attributes

 name

Detailed Description

Definition at line 61 of file atns.py.


Member Function Documentation

def Marshall.namespaces.atns.ATAttribute.deserialize (   self,
  instance,
  ns_data,
  options = {} 
)

Definition at line 116 of file atns.py.

00116 
00117     def deserialize(self, instance, ns_data, options={}):
00118         values = ns_data.get( self.name )
00119         if not values:
00120             return
00121 
00122        # check if we are a schema attribute
00123         if self.isReference( instance ):
00124             values = self.resolveReferences( instance, values)
00125             if not config.HANDLE_REFS :
00126                 return
00127 
00128         mutator = instance.Schema()[self.name].getMutator(instance)
00129         if not mutator:
00130             # read only field no mutator, but try to set value still
00131             # since it might reflect object state (like ATCriteria)
00132             field = instance.getField( self.name ).set( instance, values )
00133             #raise AttributeError("No Mutator for %s"%self.name)
00134             return
00135         
00136         if self.name == "id":
00137             transaction.savepoint()
00138         mutator(values)

Here is the call graph for this function:

def Marshall.namespaces.atns.ATAttribute.get (   self,
  instance 
)

Definition at line 63 of file atns.py.

00063 
00064     def get(self, instance):
00065         values = atapi.BaseObject.__getitem__(instance, self.name)
00066         if not isinstance( values, ( list, tuple ) ):
00067             values = [values]
00068         return filter(None, values)

Here is the caller graph for this function:

def Marshall.namespaces.atns.ATAttribute.isReference (   self,
  instance 
)

Definition at line 153 of file atns.py.

00153 
00154     def isReference(self, instance):
00155         return not not isinstance(instance.Schema()[self.name],
00156                                   atapi.ReferenceField)

Here is the caller graph for this function:

def Marshall.namespaces.atns.ATAttribute.processXmlValue (   self,
  context,
  value 
)

Definition at line 102 of file atns.py.

00102 
00103     def processXmlValue(self, context, value ):
00104         value = value.strip()
00105         if not value:
00106             return
00107         data = context.getDataFor( self.namespace.xmlns )
00108         if data.has_key( self.name ):
00109             svalues = data[self.name]
00110             if not isinstance( svalues, list):
00111                 data[self.name] = svalues = [ svalues ]
00112             svalues.append( value )
00113             return
00114         else:
00115             data[self.name] = value
        
def Marshall.namespaces.atns.ATAttribute.resolveReferences (   self,
  instance,
  values 
)

Definition at line 139 of file atns.py.

00139 
00140     def resolveReferences(self, instance, values):
00141         ref_values = []
00142         for value in values:
00143             if not isinstance( value, Reference):
00144                 ref_values.append( value )
00145                 continue
00146             ref = value.resolve( instance )
00147             if ref is None: # just for dup behavior
00148                 raise MarshallingException(
00149                     "Could not resolve reference %r"%value
00150                     )
00151             ref_values.append( ref )
00152         return ref_values
        

Here is the caller graph for this function:

def Marshall.namespaces.atns.ATAttribute.serialize (   self,
  dom,
  parent_node,
  instance,
  options = {} 
)

Definition at line 69 of file atns.py.

00069 
00070     def serialize(self, dom, parent_node, instance, options={}):
00071         
00072         values = self.get( instance )
00073         if not values:
00074             return
00075 
00076         is_ref = self.isReference( instance )
00077         
00078         for value in values:
00079             node = dom.createElementNS( self.namespace.xmlns, "field")
00080             name_attr = dom.createAttribute("name")
00081             name_attr.value = self.name
00082             node.setAttributeNode( name_attr )
00083             
00084             if is_ref:
00085                 if config.HANDLE_REFS:
00086                     ref_node = dom.createElementNS( self.namespace.xmlns,
00087                                                     'reference' )
00088                     uid_node = dom.createElementNS( self.namespace.xmlns,
00089                                                     'uid' )
00090                     value = response.createTextNode( str( value ) )
00091                     uid_node.append( value )
00092                     ref_node.append( uid_node )
00093                     node.append( ref_node )
00094             else:
00095                 value_node = dom.createTextNode( str( value ) )
00096                 node.appendChild( value_node )
00097         
00098             node.normalize()
00099             parent_node.appendChild( node )
00100 
00101         return True


Member Data Documentation

Definition at line 135 of file atns.py.


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