def request(path, method, data): """Fakes the web request. Useful when infobase is not run as a separate process. """ web.ctx.infobase_localmode = True web.ctx.infobase_input = data or {} web.ctx.infobase_method = method def get_class(classname): if '.' in classname: modname, classname = classname.rsplit('.', 1) mod = __import__(modname, None, None, ['x']) fvars = mod.__dict__ else: fvars = globals() return fvars[classname] try: # hack to make cache work for local infobase connections cache.loadhook() for pattern, classname in web.group(app.mapping, 2): m = web.re_compile('^' + pattern + '$').match(path) if m: args = m.groups() cls = get_class(classname) tocall = getattr(cls(), method) return tocall(*args) raise web.notfound() finally: # hack to make cache work for local infobase connections cache.unloadhook()
def bootstrap(self, admin_password='******'): import bootstrap web.ctx.ip = '127.0.0.1' import cache cache.loadhook() bootstrap.bootstrap(self, admin_password)
def bootstrap(site, admin_password): """Creates system types and objects for a newly created site. """ import cache cache.loadhook() import web web.ctx.infobase_bootstrap = True query = make_query() site.save_many(query) from infogami.infobase import config import random import string def random_password(length=20): chars = string.letters + string.digits return "".join(random.choice(chars) for i in range(length)) # Account Bot is not created till now. Set account_bot to None in config until he is created. account_bot = config.get("account_bot") config.account_bot = None a = site.get_account_manager() a.register(username="******", email="*****@*****.**", password=admin_password, data=dict(displayname="Administrator"), _activate=True) a.update_user_details("admin", verified=True) if account_bot: username = account_bot.split("/")[-1] a.register(username=username, email="*****@*****.**", password=random_password(), data=dict(displayname=username), _activate=True) a.update_user_details(username, verified=True) # add admin user to admin usergroup import account q = [ usergroup('/usergroup/admin', 'Group of admin users.', [{ "key": account.get_user_root() + "admin" }]) ] site.save_many(q) config.account_bot = account_bot web.ctx.infobase_bootstrap = False
def bootstrap(self, admin_password='******'): import bootstrap query = bootstrap.make_query() import cache cache.loadhook() web.ctx.ip = '127.0.0.1' self.save_many(query) a = self.get_account_manager() a.register(username="******", email="*****@*****.**", password=admin_password, data=dict(displayname="Administrator")) a.register(username="******", email="*****@*****.**", password=admin_password, data=dict(displayname="User Administrator"))
def bootstrap(site, admin_password): """Creates system types and objects for a newly created site. """ import cache cache.loadhook() import web web.ctx.infobase_bootstrap = True query = make_query() #site.write(query) site.save_many(query) a = site.get_account_manager() a.register(username="******", email="*****@*****.**", password=admin_password, data=dict(displayname="Administrator")) a.register(username="******", email="*****@*****.**", password=admin_password, data=dict(displayname="User Administrator"))
def bootstrap(site, admin_password): """Creates system types and objects for a newly created site. """ import cache cache.loadhook() import web web.ctx.infobase_bootstrap = True query = make_query() site.save_many(query) from infogami.infobase import config import random import string def random_password(length=20): chars = string.letters + string.digits return "".join(random.choice(chars) for i in range(length)) # Account Bot is not created till now. Set account_bot to None in config until he is created. account_bot = config.get("account_bot") config.account_bot = None a = site.get_account_manager() a.register(username="******", email="*****@*****.**", password=admin_password, data=dict(displayname="Administrator"), _activate=True) a.update_user_details("admin", verified=True) if account_bot: username = account_bot.split("/")[-1] a.register(username=username, email="*****@*****.**", password=random_password(), data=dict(displayname=username), _activate=True) a.update_user_details(username, verified=True) # add admin user to admin usergroup import account q = [usergroup('/usergroup/admin', 'Group of admin users.', [{"key": account.get_user_root() + "admin"}])] site.save_many(q) config.account_bot = account_bot web.ctx.infobase_bootstrap = False
def request(path, method, data): """Fakes the web request. Useful when infobase is not run as a separate process. """ web.ctx.infobase_localmode = True web.ctx.infobase_input = data or {} web.ctx.infobase_method = method def get_class(classname): if '.' in classname: modname, classname = classname.rsplit('.', 1) mod = __import__(modname, None, None, ['x']) fvars = mod.__dict__ else: fvars = globals() return fvars[classname] try: # hack to make cache work for local infobase connections cache.loadhook() mapping = app.mapping # Before web.py<0.36, the mapping is a list and need to be grouped. # From web.py 0.36 onwards, the mapping is already grouped. # Checking the type to see if we need to group them here. if mapping and not isinstance(mapping[0], (list, tuple)): mapping = web.group(mapping, 2) for pattern, classname in mapping: m = web.re_compile('^' + pattern + '$').match(path) if m: args = m.groups() cls = get_class(classname) tocall = getattr(cls(), method) return tocall(*args) raise web.notfound() finally: # hack to make cache work for local infobase connections cache.unloadhook()