Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: b24c988255
Fetching contributors…

Cannot retrieve contributors at this time

64 lines (49 sloc) 1.786 kb
""" This is an example of useing form (imperative style). """
import ptah, ptah_cms
from pprint import pprint
from paste.httpserver import serve
from pyramid.httpexceptions import HTTPFound
from memphis import view, form
class MyForm(form.Form):
view.pyramidView('test-form.html', context=ptah_cms.Content)
# define fields for form
fields = form.Fieldset(
title = u'Title'), # field title
title = u'Description',
missing = u''), # field use this value is request doesnt contain
# field value, effectively field is required
# if `missing` is not specified
title = u'E-Mail',
description = u'Please provide email address.',
validator = form.Email(), # email validator
# form default values
def getContent(self):
return {'title': self.context.title,
'description': self.context.description}
def updateAction(self):
data, errors = self.extract()
if errors:
self.message(errors, 'form-error')
self.context.title = data['title']
self.context.description = data['description']
self.message('Content has been updated.', 'info')
raise HTTPFound(location='.')
def cancelAction(self):
raise HTTPFound(location='.')
if __name__ == '__main__':
""" ...
app = ptah.make_wsgi_app({'settings':r'./ptah.ini'})
serve(app, host='')
Jump to Line
Something went wrong with that request. Please try again.