SVN: r25683 - trunk/quixote/demo
David Binger <dbinger-fVcApmY9cLvQ3/1i3zOLAti2O/[email protected]> Mon, 6 Dec 2004 19:00:54 -0500
| Newsgroups | gmane.comp.web.quixote.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: dbinger
Date: 2004-11-30 14:48:13 -0500 (Tue, 30 Nov 2004)
New Revision: 25683
Modified:
trunk/quixote/demo/extras.ptl
trunk/quixote/demo/forms.ptl
Log:
Work file upload into the basic forms demo.
Modified: trunk/quixote/demo/extras.ptl
===================================================================
--- trunk/quixote/demo/extras.ptl 2004-11-30 02:05:38 UTC (rev 25682)
+++ trunk/quixote/demo/extras.ptl 2004-11-30 19:48:13 UTC (rev 25683)
@@ -8,7 +8,7 @@
class ExtraDirectory(Resolving, Directory):
- _q_exports = ["", "form", "upload", "src"]
+ _q_exports = ["", "form", "src"]
def _q_index [html] (self):
"""
@@ -25,8 +25,6 @@
A method on a published Python object.
<li><a href="form">form</a>:
A Quixote form in action.
- <li><a href="upload">upload</a>:
- A demo of file uploads.
<li><a href="src/">src/</a>:
A static directory published through Quixote.
</ul>
Modified: trunk/quixote/demo/forms.ptl
===================================================================
--- trunk/quixote/demo/forms.ptl 2004-11-30 02:05:38 UTC (rev 25682)
+++ trunk/quixote/demo/forms.ptl 2004-11-30 19:48:13 UTC (rev 25683)
@@ -6,7 +6,7 @@
import time
from quixote.form import Form, StringWidget, PasswordWidget, \
RadiobuttonsWidget, SingleSelectWidget, MultipleSelectWidget, \
- CheckboxWidget
+ CheckboxWidget, FileWidget
from quixote.form.css import BASIC_FORM_CSS
class Topping:
@@ -33,7 +33,7 @@
def form_demo():
# build form
- form = Form()
+ form = Form(enctype="multipart/form-data") # enctype for file upload
form.add(StringWidget, "name", title="Your Name",
size=20, required=True)
form.add(PasswordWidget, "password", title="Password",
@@ -55,6 +55,7 @@
value=[TOPPINGS[0]],
options=TOPPINGS,
size=5)
+ form.add(FileWidget, "file", title="Your Pizza Specification")
form.add_hidden('time', value=time.time())
form.add_submit("go", "Go!")
@@ -98,10 +99,17 @@
value = widget.parse()
'<tr>'
' <td>%s</td>' % widget.get_name()
- ' <td>%s</td>' % type(value).__name__
+ ' <td>%s</td>' % getattr(value, str('__class__'),
+ type(value)).__name__
+ '<td>'
if value is None:
- value = "<i>None</i>"
- ' <td>%s</td>' % value
+ "<i>None</i>"
+ elif isinstance(widget, FileWidget):
+ repr(value)
+ ' (%s bytes)' % len(value.fp.read())
+ else:
+ repr(value)
+ '</td>'
'</tr>'
"""
</table>