Tip: Click lines to highlight, hold ctrl/cmd to multi-select

http://codedumper.com/eqona (25-May @ 02:43)

Syntax Highlighted Code

  1. class SimpleClientJSON(grok.JSON):
  2.     grok.context(SimpleClient)
  3.  
  4.     def firstname(self):
  5.         return {'firstname': self.context.firstname}
  6.         #return dict(client = self.context) TODO: make the object JSON serializable
  7.  
  8.     def lastname(self):
  9.         return {'lastname': self.context.lastname}
  10.  
  11. class Index(grok.View):
  12.     grok.context(rdbexample)
  13.  
  14.     def render(self):
  15.         session = Session()
  16.         client = session.query(SimpleClient).first()
  17.         if client:
  18.             view = getMultiAdapter((client, self.request), name='firstname')
  19.             return view()
  20.         else:
  21.             self.redirect('addsimpleclient')
  22.  

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')

Permalink: http://codedumper.com/eqona