Tip: Click lines to highlight, hold ctrl/cmd to multi-select
http://codedumper.com/eqona (25-May @ 02:43)
Syntax Highlighted Code
- class SimpleClientJSON(grok.JSON):
- grok.context(SimpleClient)
- def firstname(self):
- return {'firstname': self.context.firstname}
- #return dict(client = self.context) TODO: make the object JSON serializable
- def lastname(self):
- return {'lastname': self.context.lastname}
- class Index(grok.View):
- grok.context(rdbexample)
- def render(self):
- session = Session()
- client = session.query(SimpleClient).first()
- if client:
- view = getMultiAdapter((client, self.request), name='firstname')
- return view()
- else:
- self.redirect('addsimpleclient')
Plain Code
class SimpleClientJSON(grok.JSON):
grok.context(SimpleClient)
def firstname(self):
return {'firstname': self.context.firstname}
#return dict(client = self.context) TODO: make the object JSON serializable
def lastname(self):
return {'lastname': self.context.lastname}
class Index(grok.View):
grok.context(rdbexample)
def render(self):
session = Session()
client = session.query(SimpleClient).first()
if client:
view = getMultiAdapter((client, self.request), name='firstname')
return view()
else:
self.redirect('addsimpleclient')