Anonymous avatar Anonymous committed d251a1e

Implemented #478

Comments (0)

Files changed (2)

cherrypy/lib/defaultformmask.py

 """Default mask for the form.py module"""
 
+import warnings
+warnings.warn("cherrypy.lib.defaultformmask is deprecated and might disappear in future versions of CherryPy", DeprecationWarning, stacklevel = 2)
+
 from xml.sax.saxutils import quoteattr as q
 
 
         else:
             vals = [field.currentValue]
         i = '<input name=%s type="hidden" value=%%s />' % q(field.name)
-        return [i % q(v) for v in vals]
+        return ''.join([i % q(v) for v in vals])
     elif field.typ in ('checkbox', 'radio'):
         res.append('<td>')
         for option in field.optionList:

cherrypy/lib/form.py

 """Simple form handling module."""
 
+import warnings
+warnings.warn("cherrypy.lib.form is deprecated and might disappear in future versions of CherryPy", DeprecationWarning, stacklevel = 2)
+
 import cherrypy
 import defaultformmask
 
 
 class FormField:
     
-    def __init__(self, label, name, typ, mask=None, mandatory=0, size=15,
+    def __init__(self, label, name, typ, mask=None, mandatory=0, size='15',
                  optionList=[], defaultValue='', defaultMessage='', validate=None):
         self.isField = 1
         self.label = label
     
     method = "post"
     enctype = ""
-    
+
+    def __init__(self, action = "postForm", method = "post", enctype = "", header = defaultformmask.defaultHeader, footer = defaultformmask.defaultFooter, headerLabel = "", footerLabel = ""):
+        self.action = action
+        self.method = method
+        self.enctype = enctype
+        self.header = header
+        self.footer = footer
+        self.headerLabel = headerLabel
+        self.footerLabel = footerLabel
+
     def formView(self, leaveValues=0):
         if self.enctype:
             enctypeTag = 'enctype="%s"' % self.enctype
         else:
             enctypeTag = ""
         
-        res = ['<form method="%s" %s action="postForm">'
-               % (self.method, enctypeTag)]
+        res = ['<form method="%s" %s action="%s">'
+               % (self.method, enctypeTag, self.action)]
+        res.append(self.header(self.headerLabel))
+
         for field in self.fieldList:
             res.append(field.render(leaveValues))
-        res.append["</form>"]
+
+        res.append(self.footer(self.footerLabel))
+        res.append("</form>")
         
         return "".join(res)
     
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.