self.title = title if expression is not None: self.setExpression(expression) if component_name is not None: self.setComponentName(component_name) if REQUEST is not None: message = 'Predicate Constraints Changed.' return self.manage_changePredicateForm( manage_tabs_message=message, management_view='Edit') return self InitializeClass(Predicate) registerPredicate('default', 'Default Predicate', Predicate) def manage_addPredicate(self, id, title, predicate, expression, component_name, REQUEST=None): """ Factory method that creates a Property Set Predicate""" obj = createPredicate(predicate, id, title, expression, component_name) self._setObject(id, obj) if REQUEST is not None: next = 'manage_main' if hasattr(obj, 'manage_changeSettingsForm'): next = 'manage_changeSettingsForm' REQUEST['RESPONSE'].redirect('/'.join((self.absolute_url(), id, next))) return self._getOb(id)
if not body: return () try: doc = minidom.parseString(body) except: return () elm_args = filter(None, (self.getElementNS(), self.getElementName())) get_elm = (len(elm_args) == 2 and doc.getElementsByTagNameNS or doc.getElementsByTagName) elm = get_elm(*elm_args) if not elm: return () match = True elm = elm[0] attr_args = filter(None, (self.getAttributeNS(), self.getAttributeName())) if not attr_args: get_attr = lambda elm=elm: elm.firstChild.nodeValue.strip() else: get_attr = (len(attr_args) == 2 and elm.getAttributeNS or elm.getAttribute) expected = self.getValue() if expected is not None: got = get_attr(*attr_args) match = got == expected return match and retval or () InitializeClass(XMLNS) registerPredicate('xmlns_attr', 'XMLNS Element/Attribute', XMLNS)
# Try 'file', though that may bloat memory with big files :( body = f.read() f.seek(0) if not body: return () try: doc = minidom.parseString(body) except: return () elm_args = filter(None, (self.getElementNS(), self.getElementName())) get_elm = len(elm_args) == 2 and doc.getElementsByTagNameNS or doc.getElementsByTagName elm = get_elm(*elm_args) if not elm: return () match = True elm = elm[0] attr_args = filter(None, (self.getAttributeNS(), self.getAttributeName())) if not attr_args: get_attr = lambda elm=elm: elm.firstChild.nodeValue.strip() else: get_attr = len(attr_args) == 2 and elm.getAttributeNS or elm.getAttribute expected = self.getValue() if expected is not None: got = get_attr(*attr_args) match = got == expected return match and retval or () InitializeClass(XMLNS) registerPredicate("xmlns_attr", "XMLNS Element/Attribute", XMLNS)
f.seek(0) if not body: return () try: doc = minidom.parseString(body) except: return () elm_args = filter(None, (self.getElementNS(), self.getElementName())) get_elm = (len(elm_args) == 2 and doc.getElementsByTagNameNS or doc.getElementsByTagName) elm = get_elm(*elm_args) if not elm: return () match = True elm = elm[0] attr_args = filter(None, (self.getAttributeNS(), self.getAttributeName())) if not attr_args: get_attr = lambda elm=elm: elm.firstChild.nodeValue.strip() else: get_attr = (len(attr_args) == 2 and elm.getAttributeNS or elm.getAttribute) expected = self.getValue() if expected is not None: got = get_attr(*attr_args) match = got == expected return match and retval or () InitializeClass(XMLNS) registerPredicate('xmlns_attr', 'XMLNS Element/Attribute', XMLNS)
if title is not None: self.title = title if expression is not None: self.setExpression(expression) if component_name is not None: self.setComponentName(component_name) if REQUEST is not None: message = 'Predicate Constraints Changed.' return self.manage_changePredicateForm(manage_tabs_message=message, management_view='Edit') return self InitializeClass(Predicate) registerPredicate('default', 'Default Predicate', Predicate) def manage_addPredicate(self, id, title, predicate, expression, component_name, REQUEST=None): """ Factory method that creates a Property Set Predicate""" obj = createPredicate(predicate, id, title, expression, component_name) self._setObject(id, obj) if REQUEST is not None: next = 'manage_main'