Author: ianb
Date: 2004-03-17 22:54:19 -0500 (Wed, 17 Mar 2004)
New Revision: 69
Removed:
trunk/FormEncode/experimental/FormEncodeKit/Examples/address.py
Log:
removed dup file
Deleted: trunk/FormEncode/experimental/FormEncodeKit/Examples/address.py
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/FormEncode/experimental/FormEncodeKit/Examples/address.py 2004-=
03-18 03:49:45 UTC (rev 68)
+++ trunk/FormEncode/experimental/FormEncodeKit/Examples/address.py 2004-=
03-18 03:54:19 UTC (rev 69)
@@ -1,61 +0,0 @@
-from Component.CPage import CPage
-
-from formencode import validators, htmlview, schema
-from formencode.FormComponent import FormComponent
-
-class Address(CPage):
-
- components =3D [FormComponent()]
-
- class schema(schema.Schema):
-
- firstName =3D validators.String(notEmpty=3DTrue, htmlview=3Dhtml=
view.Text)
- lastName =3D validators.String(notEmpty=3DTrue, htmlview=3Dhtmlv=
iew.Text)
-
- class phone(schema.Schema):
- repeating =3D 1
- number =3D validators.PhoneNumber(ifEmpty=3DNone, htmlview=3D=
htmlview.Text)
- type =3D validators.OneOf(['home', 'work'],
- htmlview=3Dhtmlview.Select(selections=
=3D[('home', 'home'), ('work', 'work')]))
-
- repeats =3D validators.Int(htmlview=3Dhtmlview.Hidden)
-
- submit =3D validators.String(htmlview=3Dhtmlview.SubmitButton(de=
scription=3D''))
-
- def cleanup(cls, value):
- value =3D value.copy()
- value['phone'] =3D [p for p in value['phone'] if p['number']=
is not None]
- return value
- cleanup =3D classmethod(cleanup)
-
- def render(cls, value):
- s =3D 'Name: %s %s<br>\n' % (value.get('firstName'),
- value.get('lastName'))
- if value.get('phone', []):
- s +=3D '<ul>\n'
- for p in value.get('phone'):
- s +=3D '<li>%s: %s\n' % (p['type'], p['number'])
- s +=3D '</ul>\n'
- return s
- render =3D classmethod(render)
-
- def optionsAddRep(cls, value, add=3D1):
- value['repeats'] =3D len(value.get('phone', [])) + add
- return {'phone': {'repetitions': value['repeats']}}
- optionsAddRep =3D classmethod(optionsAddRep)
-
- def writeContent(self):
- ses =3D self.session()
-
- valid, address =3D self.processForm()
- if valid:
- address =3D self.schema.cleanup(address)
- ses.setValue('address', address)
- else:
- address =3D ses.value('address', {})
- self.write('<h1>Address:</h1>\n')
- self.write(self.schema.render(address))
- self.write('<hr noshade>\n')
- options =3D self.schema.optionsAddRep(address)
- self.writeForm(defaults=3Daddress, options=3Doptions)
-
|