1.1 --- a/XSLForms/Fields.py Fri Oct 07 21:34:58 2005 +0000
1.2 +++ b/XSLForms/Fields.py Sun Oct 09 00:46:12 2005 +0000
1.3 @@ -347,29 +347,75 @@
1.4 "A collection of documents processed from form fields."
1.5
1.6 def __init__(self, *args, **kw):
1.7 +
1.8 + """
1.9 + Initialise the form data container with the general 'args' and 'kw'
1.10 + parameters.
1.11 + """
1.12 +
1.13 FieldProcessor.__init__(self, *args, **kw)
1.14 self.parameters = {}
1.15 self.documents = {}
1.16
1.17 def set_parameters(self, parameters):
1.18 +
1.19 + "Set the request 'parameters' (or fields) in the container."
1.20 +
1.21 self.parameters = parameters
1.22 self.documents = self.make_documents(self.parameters.items())
1.23
1.24 def get_parameters(self):
1.25 +
1.26 + """
1.27 + Get the request parameters (or fields) from the container. Note that
1.28 + these parameters comprise the raw form field values submitted in a
1.29 + request rather than the structured form data.
1.30 +
1.31 + Return a dictionary mapping parameter names to values.
1.32 + """
1.33 +
1.34 return self.parameters
1.35
1.36 def get_documents(self):
1.37 +
1.38 + """
1.39 + Get the form data documents from the container, returning a dictionary
1.40 + mapping document names to DOM-style document objects.
1.41 + """
1.42 +
1.43 return self.documents
1.44
1.45 def get_selectors(self):
1.46 +
1.47 + """
1.48 + Get the form data selectors from the container, returning a dictionary
1.49 + mapping selector names to collections of selected elements.
1.50 + """
1.51 +
1.52 return FieldProcessor.get_selectors(self, self.parameters.items(), self.documents)
1.53
1.54 def new_instance(self, name):
1.55 +
1.56 + """
1.57 + Make a new document with the given 'name', storing it in the container
1.58 + and returning the document.
1.59 + """
1.60 +
1.61 doc = FieldProcessor.new_instance(self, name)
1.62 self.documents[name] = doc
1.63 return doc
1.64
1.65 + # An alias for the older method name.
1.66 +
1.67 + new_document = new_instance
1.68 +
1.69 def set_document(self, name, doc):
1.70 +
1.71 + """
1.72 + Store in the container under the given 'name' the supplied document
1.73 + 'doc'.
1.74 + """
1.75 +
1.76 self.documents[name] = doc
1.77
1.78 if __name__ == "__main__":