Tip: Click lines to highlight, hold ctrl/cmd to multi-select
http://codedumper.com/ocigo (26-Jun @ 01:11)
Syntax Highlighted Code
- Do a simple doctest test on the app.
- ************************************
- :Test-Layer: functional
- >>> import grok
- >>> from zope.component import getMultiAdapter
- >>> from zope import schema
- >>> from pymenthon.forms.components import AddForm
- >>> from zope.interface import Interface
- >>> from zope.publisher.browser import TestRequest
- >>> class IPerson(Interface):
- ... firstname = schema.TextLine(title=u'Firstname')
- ... lastname = schema.TextLine(title=u'Lastname')
- ...
- >>> class People(grok.Application, grok.Container):
- ... pass
- ...
- Now we can create a JSON View
- >>> class PersonJSON(grok.JSON):
- ... grok.context(People)
- ...
- ... def hello(self):
- ... return {'hi':'there'}
- ...
- Finally, let's get the view
- >>> persons = People()
- >>> request = TestRequest()
- >>> form = getMultiAdapter((persons, request), name="hello")
Plain Code
Do a simple doctest test on the app.
************************************
:Test-Layer: functional
>>> import grok
>>> from zope.component import getMultiAdapter
>>> from zope import schema
>>> from pymenthon.forms.components import AddForm
>>> from zope.interface import Interface
>>> from zope.publisher.browser import TestRequest
>>> class IPerson(Interface):
... firstname = schema.TextLine(title=u'Firstname')
... lastname = schema.TextLine(title=u'Lastname')
...
>>> class People(grok.Application, grok.Container):
... pass
...
Now we can create a JSON View
>>> class PersonJSON(grok.JSON):
... grok.context(People)
...
... def hello(self):
... return {'hi':'there'}
...
Finally, let's get the view
>>> persons = People()
>>> request = TestRequest()
>>> form = getMultiAdapter((persons, request), name="hello")