def __init__(self, default=NoDefault, name="Default"): """Create a new StackedObjectProxy If a default is given, its used in every thread if no other object has been pushed on. """ self.__dict__['____name__'] = name self.__dict__['____local__'] = threadinglocal.local() if default is not NoDefault: self.__dict__['____default_object__'] = default
def __init__(self): # Registries and their saved reglists by request_id self.saved_registry_states = {} self.restoration_context_id = threadinglocal.local()
class AppError(HTTPError): code = 500 title = '[amiweb]HTTPError:Internal Server Error' explanation = "Application error:\r\n" def __init__(self, expl): self.explanation = "[amiweb]AppError:%s%s" % (self.explanation, expl) ## # Stuff for export (should be accessed through amiweb.) # db_pool = None config = {} thread_data = local() def db(): try: #print "[amiweb]DB:before db connnection assignment<br>" db_connection = thread_data.db_connection #print "[amiweb]DBafter db connnection assignment<br>" except AttributeError: thread_data.db_connection = db_pool.getConnection() return thread_data.db_connection def request(): return thread_data.request