Controller
They are handy controller classes
API Reference
Modules
Module Attributes
__file__ =
'C:\\Documents and Settings\\James\\Desktop\\PythonWeb\\bricks\\bricks\\controller\\__inift__.pyc'
__name__ =
'bricks.controller.__inift__'
Classes
class Controllerasd
Controller
Each exposed method is expected to return an iterable (talk about efficiency) It may also call start_response if it likes but only once. The default start response is called if not. Mappings are made to variables which don't start with an underscore.
def __call__(self, environ, start_response)[show source]A very handy module for starting the class
C:\Documents and Settings\James\Desktop\PythonWeb\bricks\bricks\controller\__inift__.py 27: def __call__(self, environ, start_response): 28: "A very ``handy`` module for *starting* the class" 29: called = [] 30: self.view = View(environ) 31: #self.model = loadModel(environ) 32: def new_start_response(status, headers, exc_info=None): 33: if len(called) > 0: 34: raise Exception('start_response() already called') 35: called.append(1) 36: return start_response(status, headers, exc_info) 37: self.start_response = new_start_response 38: self.environ = environ 39: 40: self.setup() 41: 42: path = self.environ['bricks.path'].split('/') 43: methodName = 'index' 44: args = [] 45: if len(path) > 0 and path[0] <> '': 46: methodName = path[0] 47: args = path[1:] 48: if not hasattr(self, methodName): 49: raise web.wsgi.exception.HTTPError404('No such action %s'%methodName) 50: method = getattr(self, methodName) 51: if not hasattr(method,'expose'): 52: raise web.wsgi.exception.HTTPError401('Action %s is not exposed'%repr(methodName)) 53: if method.expose == 1: 54: result = method(*args) 55: if len(called) > 0: 56: return result 57: else: 58: self.start_response('200 OK', [('Content-Type', 'text/html')]) 59: return result 60: #~ for data in method(*args): 61: #~ if len(called) > 0: 62: #~ return data 63: #~ else: 64: #~ self.start_response('200 OK', [('Content-Type', 'text/html')]) 65: #~ return data 66: else: 67: if not environ.has_key('web.auth'): 68: raise Exception('Auth restrictions imposed on method %s but no auth middleware found'%(repr(methodName))) 69: if not environ.has_key('web.auth.user'): # No user signed in 70: self.start_response('403 User not signed in', []) 71: return [''] 72: elif not environ['web.auth.user'].authorise(**method.expose): 73: self.start_response('403 You do not have permission to access this application', []) 74: return [''] 75: else: 76: result = method(*args) 77: if len(called) > 0: 78: return result 79: else: 80: self.start_response('200 OK', [('Content-Type', 'text/html')]) 81: return resultdef setup(self)[show source]C:\Documents and Settings\James\Desktop\PythonWeb\bricks\bricks\controller\__inift__.py 24: def setup(self): 25: pass