Back to index

plone3  3.1.7
Classes | Functions | Variables
Marshall.namespaces.uuns Namespace Reference

Classes

class  UUAttribute
class  UUNS

Functions

def base64encode
def base64decode
def uuencode
def uudecode
def char_encode
def char_decode
def deserialize
def serialize

Variables

 DEBUG = False

Function Documentation

def Marshall.namespaces.uuns.base64decode (   self,
  string 
)

Definition at line 67 of file uuns.py.

00067 
00068     def base64decode(self, string) :
00069         return base64.decodestring(string)
        
def Marshall.namespaces.uuns.base64encode (   self,
  string 
)

Definition at line 64 of file uuns.py.

00064 
00065     def base64encode(self, string) :
00066         return base64.encodestring(string)
        
def Marshall.namespaces.uuns.char_decode (   self,
  string 
)

Definition at line 85 of file uuns.py.

00085 
00086     def char_decode(self, string) :
00087         return self.uudecode(string)
00088     

def Marshall.namespaces.uuns.char_encode (   self,
  string 
)

Definition at line 82 of file uuns.py.

00082 
00083     def char_encode(self, string) :
00084         return self.uuencode(string)

def Marshall.namespaces.uuns.deserialize (   self,
  instance,
  ns_data 
)

Definition at line 89 of file uuns.py.

00089 
00090     def deserialize(self, instance, ns_data):
00091         values = ns_data.get( self.name )
00092         if not values:
00093             return
00094         
00095         field = instance.Schema().getField(self.name)
00096         baseunit = field.getBaseUnit(instance)
00097         isBinary = baseunit.isBinary() 
00098         if isBinary :
00099             values = self.char_decode( values )
00100         
00101         mutator = instance.Schema()[self.name].getMutator(instance)
00102         if not mutator:
00103             #raise AttributeError("No Mutator for %s"%self.name)
00104             return
00105         
00106         mutator(values)
00107 

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

Definition at line 108 of file uuns.py.

00108 
00109     def serialize(self, dom, parent_node, instance):
00110         
00111         if DEBUG :
00112             print "uuns/UUattribute", instance, self.name
00113         
00114         field = instance.Schema().getField(self.name)
00115         baseunit = field.getBaseUnit(instance)
00116         value = baseunit.getRaw(encoding=baseunit.original_encoding)
00117 
00118         isBinary = baseunit.isBinary() 
00119         if isBinary :
00120             value = self.char_encode(value)
00121         
00122         elname = "%s:%s"%(self.namespace.prefix, self.name)
00123         node = dom.createElementNS( self.namespace.xmlns,
00124                                     elname )
00125         value_node = dom.createTextNode( value )
00126         node.appendChild( value_node )
00127         node.normalize()
00128         
00129         if  isBinary :
00130             id_attr = dom.createAttributeNS( self.namespace.xmlns, "binary")
00131             id_attr.value = "uuencoded"
00132             node.setAttributeNode( id_attr )
00133         
00134         parent_node.appendChild( node )
00135         
                                  
def Marshall.namespaces.uuns.uudecode (   self,
  string 
)

Definition at line 76 of file uuns.py.

00076 
00077     def uudecode(self, string) :
00078         # uu decode a srting
00079         stringio = StringIO()
00080         uu.decode(StringIO(string), stringio)
00081         return stringio.getvalue()
        
def Marshall.namespaces.uuns.uuencode (   self,
  string 
)

Definition at line 70 of file uuns.py.

00070 
00071     def uuencode(self, string) :
00072         # uu encode a srting
00073         stringio = StringIO()
00074         uu.encode(StringIO(string), stringio)
00075         return stringio.getvalue()
        

Variable Documentation

Definition at line 35 of file uuns.py.