Back to index

plone3  3.1.7
Public Member Functions | Static Public Attributes | Private Attributes
Marshall.predicates._xmlns.XMLNS Class Reference
Inheritance diagram for Marshall.predicates._xmlns.XMLNS:
Inheritance graph
[legend]
Collaboration diagram for Marshall.predicates._xmlns.XMLNS:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def edit
def apply

Static Public Attributes

tuple security = ClassSecurityInfo()
tuple getElementNS = attrMethod('_element_ns')
tuple getElementName = attrMethod('_element_name')
tuple getAttributeNS = attrMethod('_attr_ns')
tuple getAttributeName = attrMethod('_attr_name')
tuple getValue = attrMethod('_value', None)
tuple manage_options
tuple manage_changeSettingsForm

Private Attributes

 _value
 _element_ns
 _element_name
 _attr_ns
 _attr_name

Detailed Description

Predicate matching xml files on a xmlns:attribute pair.

Definition at line 35 of file _xmlns.py.


Member Function Documentation

def Marshall.predicates._xmlns.XMLNS.apply (   self,
  obj,
  kw 
)
Return component name if the rule matches, else an empty tuple.

Definition at line 86 of file _xmlns.py.

00086 
00087     def apply(self, obj, **kw):
00088         """ Return component name if the rule matches, else an empty tuple.
00089         """
00090         retval = Predicate.apply(self, obj, **kw)
00091         if not retval:
00092             return ()
00093         body = kw.get('data')
00094         if not body:
00095             f = kw.get('file')
00096             if f is None:
00097                 return ()
00098             # Try 'file', though that may bloat memory with big files :(
00099             body = f.read()
00100             f.seek(0)
00101             if not body:
00102                 return ()
00103         try:
00104             doc = minidom.parseString(body)
00105         except:
00106             return ()
00107         elm_args = filter(None, (self.getElementNS(), self.getElementName()))
00108         get_elm = (len(elm_args) == 2 and doc.getElementsByTagNameNS
00109                    or doc.getElementsByTagName)
00110         elm = get_elm(*elm_args)
00111         if not elm:
00112             return ()
00113         match = True
00114         elm = elm[0]
00115         attr_args = filter(None, (self.getAttributeNS(), self.getAttributeName()))
00116         if not attr_args:
00117             get_attr = lambda elm=elm: elm.firstChild.nodeValue.strip()
00118         else:
00119             get_attr = (len(attr_args) == 2 and elm.getAttributeNS or
00120                         elm.getAttribute)
00121         expected = self.getValue()
00122         if expected is not None:
00123             got = get_attr(*attr_args)
00124             match = got == expected
00125         return match and retval or ()
00126 
00127 InitializeClass(XMLNS)
00128 registerPredicate('xmlns_attr', 'XMLNS Element/Attribute', XMLNS)

Here is the call graph for this function:

def Marshall.predicates._xmlns.XMLNS.edit (   self,
  element_ns = '',
  element_name = '',
  attr_ns = '',
  attr_name = '',
  value = '',
  REQUEST = None 
)
Change settings germane to this predicate

Definition at line 66 of file _xmlns.py.

00066 
00067              attr_ns='', attr_name='', value='', REQUEST=None):
00068         """Change settings germane to this predicate
00069         """
00070 
00071         for n in (element_ns, element_name, attr_ns, attr_name):
00072             if not isinstance(n, basestring):
00073                 raise TypeError, 'string required, got %r.' % n
00074         self._value = value
00075         self._element_ns = element_ns
00076         self._element_name = element_name
00077         self._attr_ns = attr_ns
00078         self._attr_name = attr_name
00079 
00080         if REQUEST is not None:
00081             message = 'Predicate Settings Changed.'
00082             return self.manage_changeSettingsForm(
00083                 manage_tabs_message=message,
00084                 management_view='Settings')

Here is the caller graph for this function:


Member Data Documentation

Definition at line 77 of file _xmlns.py.

Definition at line 76 of file _xmlns.py.

Definition at line 75 of file _xmlns.py.

Definition at line 74 of file _xmlns.py.

Definition at line 73 of file _xmlns.py.

Definition at line 47 of file _xmlns.py.

Definition at line 46 of file _xmlns.py.

Definition at line 45 of file _xmlns.py.

Definition at line 44 of file _xmlns.py.

Definition at line 48 of file _xmlns.py.

Initial value:
PageTemplateFile(
        '../www/xmlnsSettings', globals(),
        __name__='manage_changeSettingsForm')

Definition at line 58 of file _xmlns.py.

Initial value:
(
        Predicate.manage_options[0],
        {'label':'Settings', 'action':'manage_changeSettingsForm'},
        )

Definition at line 50 of file _xmlns.py.

tuple Marshall.predicates._xmlns.XMLNS.security = ClassSecurityInfo() [static]

Definition at line 39 of file _xmlns.py.


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