ship/computer/browser/computer.py:
1 from zope.publisher.browser import BrowserPage
2 from zope.app.pagetemplate import ViewPageTemplateFile
3 from zope.formlib.namedtemplate import NamedTemplate,NamedTemplateImplementation
4 from zope.formlib.form import EditForm, Fields, AddForm, applyChanges
5 from zope.component import createObject
6 from ship.computer.interfaces import IComputer
...
12 class ComputerEditForm(EditForm):
13 """Basic EditForm for Editing Existing Computer Objects"""
14 form_fields = Fields(IComputer)
15 label = u"Edit Computer"
16
17 class ComputerAddForm(AddForm):
18 """Basic AddForm for adding new Computer Objects with user specified data"""
19 form_fields = Fields(IComputer)
20 label = u"Add Computer"
21
22 template = NamedTemplate('computer.addform')
23
24 def create(self, data):
25 computer = createObject(u"ship.Computer")
26 applyChanges(computer, self.form_fields, data)
27 return computer
28
29 form_template = NamedTemplateImplementation(
30 ViewPageTemplateFile('templates/compForm.pt'))
ship/computer/browser/configure.zcml:
...
5
6
...
21
28
29
30
36
37
...