[Subversion] / WebHaiku / web_haiku.py  

Diff of /WebHaiku/web_haiku.py

Parent Directory | Revision Log

version 2278, Wed Jan 24 03:06:24 2007 UTC version 2443, Sat Dec 22 16:19:03 2007 UTC
Line 1 
Line 1 
 """Yet another WSGI micro-framework..."""  """Yet another WSGI micro-framework..."""
   
 import cgi, string, new, sys  import cgi, string, new, sys
 from wsgiref.util import shift_path_info, application_uri  from wsgiref.util import shift_path_info, application_uri
   from peak import context
   
 __all__ = [  __all__ = [
     "Page", "form_handler", "HTML", "Text", "Template", "HTTP", "expose",      "Page", "form_handler", "HTML", "Text", "Template", "HTTP", "expose",
     "test", "Redirector", "EvalTemplate", "EvalMap", "Method",      "test", "Redirector", "EvalTemplate", "EvalMap", "Method", "DB"
 ]  ]
   
 class Method(object):  class Method(object):
Line 449 
Line 449 
   
   
   
   class DB(context.Service):
     db = None   # DBAPI database connection object      db = None   # DBAPI database connection object
   
     def db_connect(self):      def db_connect(self):
         """Override this in a subclass to return a DBAPI connection object"""          """Override this in a subclass to return a DBAPI connection object"""
         raise NotImplementedError          raise NotImplementedError
   
       def get_db(self):
           if self.db is None:
               self.db = self.db_connect()
           return self.db
   
     def cursor(self, *args, **kw):      def cursor(self, *args, **kw):
         """Create and return a cursor (after optionally running a query on it)          """Create and return a cursor (after optionally running a query on it)
   
Line 463 
Line 469 
         used to set cursor attributes prior to the ``execute()`` (if          used to set cursor attributes prior to the ``execute()`` (if
         applicable).          applicable).
         """          """
         db = self.db          cursor = self.get_db().cursor()
         if db is None:  
             db = self.db = self.db_connect()  
   
         cursor = db.cursor()  
         for k, v in kw.items():          for k, v in kw.items():
             setattr(cursor, k, v)              setattr(cursor, k, v)
   
Line 488 
Line 490 
         self.__dict__ = dict(zip([d[0]for d in cursor.description], row))          self.__dict__ = dict(zip([d[0]for d in cursor.description], row))
   
   
   
   
 def test(app, environ={}, form={}, **kw):  def test(app, environ={}, form={}, **kw):
     """Print the output of a WSGI app      """Print the output of a WSGI app
   


Generate output suitable for use with a patch program
Legend:
Removed from v.2278  
changed lines
  Added in v.2443

cvs-admin@eby-sarna.com

Powered by ViewCVS 1.0-dev

ViewCVS and CVS Help