Ignore:
Timestamp:
Jan 5, 2010, 2:55:40 PM (12 years ago)
Author:
Ralph Meijer <ralphm@…>
Branch:
default
Message:

Move findForm to wokkel.data_form

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wokkel/data_form.py

    r79 r80  
    654654        for field in filtered:
    655655            self.removeField(field)
     656
     657
     658
     659def findForm(element, formNamespace):
     660    """
     661    Find a Data Form.
     662
     663    Look for an element that represents a Data Form with the specified
     664    form namespace as a child element of the given element.
     665    """
     666    if not element:
     667        return None
     668
     669    for child in element.elements():
     670        if (child.uri, child.name) == ((NS_X_DATA, 'x')):
     671            form = Form.fromElement(child)
     672
     673            if (form.formNamespace == formNamespace or
     674                not form.formNamespace and form.formType=='cancel'):
     675                return form
     676
     677    return None
Note: See TracChangeset for help on using the changeset viewer.