Back to index

plone3  3.1.7
Public Member Functions
Marshall.namespaces.cmfns.LocalRolesAttribute Class Reference
Inheritance diagram for Marshall.namespaces.cmfns.LocalRolesAttribute:
Inheritance graph
[legend]
Collaboration diagram for Marshall.namespaces.cmfns.LocalRolesAttribute:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def getAttributeNames
def get
def deserialize
def serialize
def processXml

Detailed Description

serializes local roles into the form of

<security>

  <local_role user_id="matz" role"bar" />
  <local_role user_id="john" role"manager" />
  <local_role user_id="john" role"owner" />
  <local_role user_id="mike" role"manager" />

</security>

Definition at line 88 of file cmfns.py.


Member Function Documentation

def Marshall.namespaces.cmfns.LocalRolesAttribute.deserialize (   self,
  instance,
  ns_data 
)

Definition at line 110 of file cmfns.py.

00110 
00111     def deserialize(self, instance, ns_data):
00112         values = ns_data.get(self.name)
00113         if not values:
00114             return
00115         for user_id, role in values:
00116             instance.manage_addLocalRoles( user_id, [role])

Here is the call graph for this function:

def Marshall.namespaces.cmfns.LocalRolesAttribute.get (   self,
  instance 
)

Definition at line 107 of file cmfns.py.

00107 
00108     def get(self, instance):
00109         return getattr( instance, '__ac_local_roles__', {})

Here is the caller graph for this function:

Definition at line 104 of file cmfns.py.

00104 
00105     def getAttributeNames(self):
00106         return (self.name,)
    

Here is the call graph for this function:

def Marshall.namespaces.cmfns.LocalRolesAttribute.processXml (   self,
  context,
  ctx_node 
)

Definition at line 141 of file cmfns.py.

00141 
00142     def processXml(self, context, ctx_node):
00143         value = context.reader.Value()
00144         if value is None:
00145             return
00146         value = value.strip()
00147         if not value:
00148             return
00149 
00150         data = context.getDataFor( self.namespace.xmlns )
00151         values = data.setdefault(self.name, [])
00152         user_id = role = None
00153         
00154         while context.reader.MoveToNextAttribute():            
00155             if context.reader.LocalName() == 'user_id':
00156                 user_id = reader.Value()
00157             elif context.reader.LocalName() == 'role':
00158                 role = context.reader.Value()
00159 
00160         assert user_id, role
00161         values.append( (user_id, role ) )
00162             

Here is the call graph for this function:

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

Definition at line 117 of file cmfns.py.

00117 
00118     def serialize(self, dom, parent_node, instance):
00119         values = self.get(instance)
00120 
00121         if not values:
00122             return
00123 
00124         elname = "%s:%s"%(self.namespace.prefix, "security")
00125         node = dom.createElementNS( CMF.xmlns,  elname )
00126 
00127         for user_id, roles in values.items():
00128             for role in roles:
00129                 elname = "%s:%s"%(self.namespace.prefix, self.name )
00130                 lr_node = dom.createElementNS( CMF.xmlns, elname )
00131                 user_attr = dom.createAttribute("user_id")
00132                 user_attr.value = user_id
00133                 lr_node.setAttributeNode( user_attr )
00134                 
00135                 role_attr = dom.createAttribute( "role")
00136                 role_attr.value = role
00137                 lr_node.setAttributeNode( role_attr )
00138                 node.appendChild( lr_node )
00139         
00140         parent_node.appendChild( node )


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