class BaseTestScheduler(unittest.TestCase): def setUp(self): self.db = None self.cleanfolder() from gluon.globals import current s = Storage({'application': 'welcome', 'folder': 'applications/welcome', 'controller': 'default'}) current.request = s T = TranslatorFactory('', 'en') current.T = T self.db = DAL('sqlite://dummy2.db', check_reserved=['all']) def cleanfolder(self): if self.db: self.db.close() try: os.unlink('dummy2.db') except: pass tfiles = glob.glob('*_scheduler*.table') for a in tfiles: os.unlink(a) def tearDown(self): self.cleanfolder() try: self.inner_teardown() except: pass
class TestSQLTABLE(unittest.TestCase): def setUp(self): request = Request(env={}) request.application = "a" request.controller = "c" request.function = "f" request.folder = "applications/admin" response = Response() session = Session() T = translator("", "en") session.connect(request, response) from gluon.globals import current current.request = request current.response = response current.session = session current.T = T self.db = DAL(DEFAULT_URI, check_reserved=["all"]) self.auth = Auth(self.db) self.auth.define_tables(username=True, signature=False) self.db.define_table("t0", Field("tt"), self.auth.signature) self.auth.enable_record_versioning(self.db) # Create a user self.db.auth_user.insert( first_name="Bart", last_name="Simpson", username="******", email="*****@*****.**", password="******", registration_key=None, registration_id=None, ) self.db.commit()
def define_table(tablename,fieldcount): db = DAL('mysql://*****:*****@localhost:3306/test') fields=[] fields.append(Field('id','id')) fields.extend([Field('field_%d'%i,'string') for i in range(fieldcount)]) db.define_table(tablename,*fields) return db
def __init__(self, classes=[]): self._LAZY_TABLES = {} self._lazy_tables = {} self._tables = {} from gluon import current self.request = current.request self.session = current.session self.response = current.response self.T = current.T self.CURL = current.CURL self.cache = current.cache self.TIMEFORMAT = current.TIMEFORMAT self.DATEFORMAT = current.DATEFORMAT self.pdate = current.pdate self.ftime = current.ftime self.get_image = current.get_image from config import Config self.config = Config() if not current.request.env.web2py_runtime_gae: self._LAZY_TABLES = [] # needed because of lazydal DAL.__init__(self, self.config.db.uri, migrate_enabled=self.config.db.migrate_enabled, check_reserved=['all']) #session does not works well in db (why?) #current.session.connect(current.request, current.response, db=self) else: DAL.__init__(self, self.config.db.gaeuri) current.session.connect(current.request, current.response, db=self) if classes: self.define_classes(classes)
def __init__(self, classes=[]): from gluon import current self.request = current.request self.session = current.session self.response = current.response self.T = current.T self.CURL = current.CURL self.cache = current.cache self.TIMEFORMAT = current.TIMEFORMAT self.DATEFORMAT = current.DATEFORMAT self.pdate = current.pdate self.ftime = current.ftime self.get_image = current.get_image from config import Config self.config = Config() if not current.request.env.web2py_runtime_gae: DAL.__init__( self, self.config.db.uri, migrate_enabled=self.config.db.migrate_enabled, check_reserved=["all"] ) else: DAL.__init__(self, self.config.db.gaeuri) current.session.connect(current.request, current.response, db=self) if classes: self.define_classes(classes)
class TestSQLTABLE(unittest.TestCase): def setUp(self): request = Request(env={}) request.application = 'a' request.controller = 'c' request.function = 'f' request.folder = 'applications/admin' response = Response() session = Session() T = translator('', 'en') session.connect(request, response) from gluon.globals import current current.request = request current.response = response current.session = session current.T = T self.db = DAL(DEFAULT_URI, check_reserved=['all']) self.auth = Auth(self.db) self.auth.define_tables(username=True, signature=False) self.db.define_table('t0', Field('tt'), self.auth.signature) self.auth.enable_record_versioning(self.db) # Create a user self.db.auth_user.insert(first_name='Bart', last_name='Simpson', username='******', email='*****@*****.**', password='******', registration_key=None, registration_id=None) self.db.commit()
def testRun(self): from gluon.serializers import custom_json, xml from gluon import sqlhtml db = DAL(check_reserved=['all']) self.assertEqual(db.serializers['json'], custom_json) self.assertEqual(db.serializers['xml'], xml) self.assertEqual(db.representers['rows_render'], sqlhtml.represent) self.assertEqual(db.representers['rows_xml'], sqlhtml.SQLTABLE) db.close()
def __init__(self, config, datamodels=None): self._LAZY_TABLES = dict() self._tables = dict() self.config = config DAL.__init__(self, **config.db) if datamodels: self.define_datamodels(datamodels)
def testSerialization(self): import pickle db = DAL(check_reserved=['all']) db.define_table('t_a', Field('f_a')) db.t_a.insert(f_a='test') a = db(db.t_a.id>0).select(cacheable=True) s = pickle.dumps(a) b = pickle.loads(s) self.assertEqual(a.db, b.db)
def __init__(self, config): """ :param config: """ self._tables = dict() self.config = config DAL.__init__(self, **config.db)
def from5(db): return db_old = DAL( "sqlite://storage.sqlite", #pool_size=1, #check_reserved=['all'], # this keyword buil model on fly on load auto_import=True, folder="../../ipay5-m/databases") db_new = DAL( "sqlite://storage.sqlite", #pool_size=1, #check_reserved=['all'], # this keyword buil model on fly on load auto_import=True, folder="../../ipay6-a/databases") import json print '\nimport 5 to 6' for xcurr in db(db.xcurrs).select(): pass deal = db(db.deals.name == 'to phone +7 RUBs').select().first() if not deal: return 'not deal "to phone +7 RUBs"' print "for deal:", deal for rec in db_old(db_old.to_phone).select(): # найдем неимпортированные записи # acc = db((db.deal_accs.deal_id == deal.id) & (db.deal_accs.acc == rec.phone)).select().first() #print acc #continue if acc: acc_id = acc.id else: print 'insert deal_acc', rec.phone acc_id = db.deal_accs.insert(deal_id=deal.id, acc=rec.phone) acc_addr = db( (db.deal_acc_addrs.deal_acc_id == acc_id) & (db.deal_acc_addrs.addr == rec.wallet) & (db.deal_acc_addrs.xcurr_id == rec.xcurr_id)).select().first() if acc_addr: continue print 'insert acc_addr ', rec.xcurr_id, rec.wallet db.deal_acc_addrs.insert(deal_acc_id=acc_id, addr=rec.wallet, xcurr_id=rec.xcurr_id, incomed=rec.unspent, converted=rec.unspent) ####### теперь платежи #for p_in in db_old(db_old.payments).select(): db_old.close()
def test_IS_NOT_IN_DB(self): from gluon.dal import DAL, Field db = DAL('sqlite:memory') db.define_table('person', Field('name')) db.person.insert(name='george') rtn = IS_NOT_IN_DB(db, 'person.name', error_message='oops')('george') self.assertEqual(rtn, ('george', 'oops')) rtn = IS_NOT_IN_DB(db, 'person.name')('jerry') self.assertEqual(rtn, ('jerry', None)) db.person.drop()
def testSerialization(self): import pickle db = DAL(check_reserved=["all"]) db.define_table("t_a", Field("f_a")) db.t_a.insert(f_a="test") a = db(db.t_a.id > 0).select(cacheable=True) s = pickle.dumps(a) b = pickle.loads(s) self.assertEqual(a.db, b.db)
def setUp(self): self.db = None self.cleanfolder() from gluon import current s = Storage({'application': 'welcome', 'folder': 'applications/welcome', 'controller': 'default'}) current.request = s T = translator('', 'en') current.T = T self.db = DAL('sqlite://dummy2.db', check_reserved=['all'])
def testRun(self): # setup request = Request(env={}) request.application = 'a' request.controller = 'c' request.function = 'f' request.folder = 'applications/admin' response = Response() session = Session() T = translator('', 'en') session.connect(request, response) from gluon.globals import current current.request = request current.response = response current.session = session current.T = T db = DAL(DEFAULT_URI, check_reserved=['all']) auth = Auth(db) auth.define_tables(username=True, signature=False) self.assertTrue('auth_user' in db) self.assertTrue('auth_group' in db) self.assertTrue('auth_membership' in db) self.assertTrue('auth_permission' in db) self.assertTrue('auth_event' in db) db.define_table('t0', Field('tt'), auth.signature) auth.enable_record_versioning(db) self.assertTrue('t0_archive' in db) for f in [ 'login', 'register', 'retrieve_password', 'retrieve_username' ]: html_form = getattr(auth, f)().xml() self.assertTrue('name="_formkey"' in html_form) for f in [ 'logout', 'verify_email', 'reset_password', 'change_password', 'profile', 'groups' ]: self.assertRaisesRegexp(HTTP, "303*", getattr(auth, f)) self.assertRaisesRegexp(HTTP, "401*", auth.impersonate) try: for t in [ 't0_archive', 't0', 'auth_cas', 'auth_event', 'auth_membership', 'auth_permission', 'auth_group', 'auth_user' ]: db[t].drop() except SyntaxError as e: # GAE doesn't support drop pass return
def testDALcache(self): s = Storage({'application': 'admin', 'folder': 'applications/admin'}) cache = Cache(s) db = DAL(check_reserved=['all']) db.define_table('t_a', Field('f_a')) db.t_a.insert(f_a='test') db.commit() a = db(db.t_a.id > 0).select(cache=(cache.ram, 60), cacheable=True) b = db(db.t_a.id > 0).select(cache=(cache.ram, 60), cacheable=True) self.assertEqual(a.as_csv(), b.as_csv()) c = db(db.t_a.id > 0).select(cache=(cache.disk, 60), cacheable=True) d = db(db.t_a.id > 0).select(cache=(cache.disk, 60), cacheable=True) self.assertEqual(c.as_csv(), d.as_csv()) self.assertEqual(a.as_csv(), c.as_csv()) self.assertEqual(b.as_csv(), d.as_csv()) e = db(db.t_a.id > 0).select(cache=(cache.disk, 60)) f = db(db.t_a.id > 0).select(cache=(cache.disk, 60)) self.assertEqual(e.as_csv(), f.as_csv()) self.assertEqual(a.as_csv(), f.as_csv()) g = db(db.t_a.id > 0).select(cache=(cache.ram, 60)) h = db(db.t_a.id > 0).select(cache=(cache.ram, 60)) self.assertEqual(g.as_csv(), h.as_csv()) self.assertEqual(a.as_csv(), h.as_csv()) db.t_a.drop() db.close()
def setUp(self): #self.driver = webdriver.Firefox() self.driver = webdriver.Remote(command_executor='http://0.0.0.0:4444/wd/hub', desired_capabilities=DesiredCapabilities.FIREFOX) self.submit_button = "//input[@value='Submit']" db_username_postgres = 'postgres' db_password_postgres = '1234' db_postgres_url = 'postgres://' + db_username_postgres + ':' + db_password_postgres + '@localhost/dev' path_to_database = path.join(path.curdir, "../databases") self.db_test = DAL(db_postgres_url, folder=path_to_database) self.db_test.import_table_definitions(path_to_database)
def testRun(self): import gluon.serializers as mserializers from gluon import sqlhtml db = DAL(check_reserved=['all']) self.assertEqual(db.serializers, mserializers) self.assertEqual(db.representers['rows_render'], sqlhtml.represent) self.assertEqual(db.representers['rows_xml'], sqlhtml.SQLTABLE)
def define_table(self): fakeauth = Auth(DAL(None)) self.fields.extend([fakeauth.signature]) self.entity = self.db.define_table(self.tablename, *self.fields, **dict(migrate=self.migrate, format=self.format))
def toolbar(self): from html import DIV, SCRIPT, BEAUTIFY, TAG, URL, A BUTTON = TAG.button admin = URL("admin", "default", "design", args=current.request.application) from gluon.dal import DAL dbstats = [] dbtables = {} infos = DAL.get_instances() for k, v in infos.iteritems(): dbstats.append(TABLE(*[TR(PRE(row[0]), "%.2fms" % (row[1] * 1000)) for row in v["dbstats"]])) dbtables[k] = dict( defined=v["dbtables"]["defined"] or "[no defined tables]", lazy=v["dbtables"]["lazy"] or "[no lazy tables]", ) u = web2py_uuid() backtotop = A("Back to top", _href="#totop-%s" % u) return DIV( BUTTON("design", _onclick="document.location='%s'" % admin), BUTTON("request", _onclick="jQuery('#request-%s').slideToggle()" % u), BUTTON("response", _onclick="jQuery('#response-%s').slideToggle()" % u), BUTTON("session", _onclick="jQuery('#session-%s').slideToggle()" % u), BUTTON("db tables", _onclick="jQuery('#db-tables-%s').slideToggle()" % u), BUTTON("db stats", _onclick="jQuery('#db-stats-%s').slideToggle()" % u), DIV(BEAUTIFY(current.request), backtotop, _class="hidden", _id="request-%s" % u), DIV(BEAUTIFY(current.session), backtotop, _class="hidden", _id="session-%s" % u), DIV(BEAUTIFY(current.response), backtotop, _class="hidden", _id="response-%s" % u), DIV(BEAUTIFY(dbtables), backtotop, _class="hidden", _id="db-tables-%s" % u), DIV(BEAUTIFY(dbstats), backtotop, _class="hidden", _id="db-stats-%s" % u), SCRIPT("jQuery('.hidden').hide()"), _id="totop-%s" % u, )
def test2(): from gluon.dal import DAL db = DAL( "sqlite://storage.sqlite", #pool_size=1, #check_reserved=['all'], # this keyword buil model on fly on load auto_import=True, folder="../databases") # задаим дату-время при котором будут считатья записи устаревшими expired = datetime.datetime.now() - datetime.timedelta(0, 600) # 2-BTC, 5-RUB c1, x, e = get_currs_by_abbrev(db, 'BTC').id c2, x, e = get_currs_by_abbrev(db, 'RUB').id pair = db((db.exchg_pairs.curr1_id == c1.id) & (db.exchg_pairs.curr2_id == c2.id)).select().first() for vol in (1, 10, 100, 1000, 10000, 33000): #print "\n", vol #print "--->" best_price, best_pair, best_tax, best_fee_ed = get_best_price_for_volume( db, x1_id, x2_id, vol, expired) # и проверим обратную #print "<<<<" rateB, rateS, rateA = rates_lib.get_average_rate_bsa( db, x2_id, x1_id, expired) #print "rateB, rateS, rateA", rateB, rateS, rateA if rateS: best_price, best_pair, best_tax, best_fee_ed = get_best_price_for_volume( db, x2_id, x1_id, vol / rateS, expired)
def __init__(self, conn='sqlite://temp.db', pool_size=0, migrate=True): """ Generates a connection with the given DB. @connection: system path to the sqlite file to use or DB connection string. If None given, a default temp.db file will be created. """ if '://' not in conn: print """Connection string needed!\n \ Some examples:\n \ SQLite sqlite://storage.db MySQL mysql://username:password@localhost/test \ PostgreSQL postgres://username:password@localhost/test """ sys.exit(2) self._conn = conn self._db = DAL(conn, folder=PATH, pool_size=pool_size) self._db.define_table('documents', Field('key'), Field('data', 'text'), Field('valid', 'boolean'), migrate = migrate) if not self._db(self._db.documents).count(): try: self._db.executesql('CREATE INDEX keyx ON documents (key)') #CREATE INDEX IF NOT EXISTS except Exception: self._db.rollback()
class Contact(object): """Build a Contact object""" def __init__(self): self.db = DAL("sqlite://mydb.sqlite") self.session = current.session self.request = current.request self.response = current.response self.cache = current.cache self.define_table() self.set_validators() def define_table(self): self.contact = self.db.define_table("contact", Field("name"), Field("email"), Field("phone") ) def set_validators(self): self.contact.name.requires = IS_NOT_EMPTY() self.contact.email.requires = IS_EMAIL() self.contact.phone.requires = IS_LENGTH(14) def form(self, formstyle): return SQLFORM(self.contact, formstyle=formstyle).process() def load(self, scope, limitby=None): queries = {"all": self.contact.id>0, "gmailers": self.contact.email.like("%gmail.com%")} return self.db(queries[scope]).select(limitby=limitby)
def setUp(self): self.request = Request(env={}) self.request.application = 'a' self.request.controller = 'c' self.request.function = 'f' self.request.folder = 'applications/admin' self.response = Response() self.session = Session() T = translator('', 'en') self.session.connect(self.request, self.response) from gluon.globals import current self.current = current self.current.request = self.request self.current.response = self.response self.current.session = self.session self.current.T = T self.db = DAL(DEFAULT_URI, check_reserved=['all']) self.auth = AuthAPI(self.db) self.auth.define_tables(username=True, signature=False) # Create a user self.auth.table_user().validate_and_insert(first_name='Bart', last_name='Simpson', username='******', email='*****@*****.**', password='******', registration_key='', registration_id='' ) self.db.commit()
def testRun(self): # setup request = Request(env={}) request.application = 'a' request.controller = 'c' request.function = 'f' request.folder = 'applications/admin' response = Response() session = Session() T = translator('', 'en') session.connect(request, response) from gluon.globals import current current.request = request current.response = response current.session = session current.T = T db = DAL(DEFAULT_URI, check_reserved=['all']) auth = Auth(db) auth.define_tables(username=True, signature=False) self.assertTrue('auth_user' in db) self.assertTrue('auth_group' in db) self.assertTrue('auth_membership' in db) self.assertTrue('auth_permission' in db) self.assertTrue('auth_event' in db) db.define_table('t0', Field('tt'), auth.signature) auth.enable_record_versioning(db) self.assertTrue('t0_archive' in db) for f in ['login', 'register', 'retrieve_password', 'retrieve_username']: html_form = getattr(auth, f)().xml() self.assertTrue('name="_formkey"' in html_form) for f in ['logout', 'verify_email', 'reset_password', 'change_password', 'profile', 'groups']: self.assertRaisesRegexp(HTTP, "303*", getattr(auth, f)) self.assertRaisesRegexp(HTTP, "401*", auth.impersonate) try: for t in ['t0_archive', 't0', 'auth_cas', 'auth_event', 'auth_membership', 'auth_permission', 'auth_group', 'auth_user']: db[t].drop() except SyntaxError as e: # GAE doesn't support drop pass return
def __init__(self): self.db = DAL("sqlite://mydb.sqlite") self.session = current.session self.request = current.request self.response = current.response self.cache = current.cache self.define_table() self.set_validators()
def __init__(self): """Class initialization function """ # DGF connection. Please use read only user try: if IN_DGF: self.rdb = DAL("mssql://*****:*****@192.168.20.7/DGF", migrate_enabled=False, migrate=False) else: self.rdb = DAL('sqlite://dgf_database.db', migrate_enabled=False, migrate=False) self.session = current.session self.request = current.request self.response = current.response self.cache = current.cache self.__define_tables() print self.rdb.tables() except: print "DGFModel: Can't load database!."
def test_DALcache(self): s = Storage({'application': 'admin', 'folder': 'applications/admin'}) cache = Cache(s) db = DAL(check_reserved=['all']) db.define_table('t_a', Field('f_a')) db.t_a.insert(f_a='test') db.commit() a = db(db.t_a.id > 0).select(cache=(cache.ram, 60), cacheable=True) b = db(db.t_a.id > 0).select(cache=(cache.ram, 60), cacheable=True) self.assertEqual(a.as_csv(), b.as_csv()) c = db(db.t_a.id > 0).select(cache=(cache.disk, 60), cacheable=True) d = db(db.t_a.id > 0).select(cache=(cache.disk, 60), cacheable=True) self.assertEqual(c.as_csv(), d.as_csv()) self.assertEqual(a.as_csv(), c.as_csv()) self.assertEqual(b.as_csv(), d.as_csv()) e = db(db.t_a.id > 0).select(cache=(cache.disk, 60)) f = db(db.t_a.id > 0).select(cache=(cache.disk, 60)) self.assertEqual(e.as_csv(), f.as_csv()) self.assertEqual(a.as_csv(), f.as_csv()) g = db(db.t_a.id > 0).select(cache=(cache.ram, 60)) h = db(db.t_a.id > 0).select(cache=(cache.ram, 60)) self.assertEqual(g.as_csv(), h.as_csv()) self.assertEqual(a.as_csv(), h.as_csv()) db.t_a.drop() db.close()
def toolbar(self): from html import DIV, SCRIPT, BEAUTIFY, TAG, URL, A BUTTON = TAG.button admin = URL("admin", "default", "design", args=current.request.application) from gluon.dal import DAL dbstats = [] dbtables = {} infos = DAL.get_instances() for k, v in infos.iteritems(): dbstats.append( TABLE(*[ TR(PRE(row[0]), '%.2fms' % (row[1] * 1000)) for row in v['dbstats'] ])) dbtables[k] = dict(defined=v['dbtables']['defined'] or '[no defined tables]', lazy=v['dbtables']['lazy'] or '[no lazy tables]') u = web2py_uuid() backtotop = A('Back to top', _href="#totop-%s" % u) return DIV(BUTTON('design', _onclick="document.location='%s'" % admin), BUTTON('request', _onclick="jQuery('#request-%s').slideToggle()" % u), BUTTON('response', _onclick="jQuery('#response-%s').slideToggle()" % u), BUTTON('session', _onclick="jQuery('#session-%s').slideToggle()" % u), BUTTON('db tables', _onclick="jQuery('#db-tables-%s').slideToggle()" % u), BUTTON('db stats', _onclick="jQuery('#db-stats-%s').slideToggle()" % u), DIV(BEAUTIFY(current.request), backtotop, _class="hidden", _id="request-%s" % u), DIV(BEAUTIFY(current.session), backtotop, _class="hidden", _id="session-%s" % u), DIV(BEAUTIFY(current.response), backtotop, _class="hidden", _id="response-%s" % u), DIV(BEAUTIFY(dbtables), backtotop, _class="hidden", _id="db-tables-%s" % u), DIV(BEAUTIFY(dbstats), backtotop, _class="hidden", _id="db-stats-%s" % u), SCRIPT("jQuery('.hidden').hide()"), _id="totop-%s" % u)
def qq(): db = DAL('postgres://*****:*****@localhost/Lean',pool_size=5,check_reserved=['postgres'], folder=None, bigint_id=True ) #fake_migrate_all=True migrate_enabled=True db.executesql('SET search_path TO public, admins, model_gen, history, tasks, trac;') db.define_table('a_tbl', Field('name')) db.define_table('b_tbl', Field('id', 'reference a_tbl') ,Field('name'), primarykey=['id']) db.define_table('c_tbl', Field('id', 'reference b_tbl') ,Field('name'), primarykey=['id'])
class TestSQLTABLE(unittest.TestCase): def setUp(self): request = Request(env={}) request.application = "a" request.controller = "c" request.function = "f" request.folder = "applications/admin" response = Response() session = Session() T = translator("", "en") session.connect(request, response) from gluon.globals import current current.request = request current.response = response current.session = session current.T = T self.db = DAL(DEFAULT_URI, check_reserved=["all"]) self.auth = Auth(self.db) self.auth.define_tables(username=True, signature=False) self.db.define_table("t0", Field("tt"), self.auth.signature) self.auth.enable_record_versioning(self.db) # Create a user self.db.auth_user.insert( first_name="Bart", last_name="Simpson", username="******", email="*****@*****.**", password="******", registration_key=None, registration_id=None, ) self.db.commit() def test_SQLTABLE(self): rows = self.db(self.db.auth_user.id > 0).select(self.db.auth_user.ALL) sqltable = SQLTABLE(rows) self.assertEqual( sqltable.xml(), '<table><thead><tr><th>auth_user.id</th><th>auth_user.first_name</th><th>auth_user.last_name</th><th>auth_user.email</th><th>auth_user.username</th><th>auth_user.password</th><th>auth_user.registration_key</th><th>auth_user.reset_password_key</th><th>auth_user.registration_id</th></tr></thead><tbody><tr class="w2p_odd odd"><td>1</td><td>Bart</td><td>Simpson</td><td>[email protected]</td><td>user1</td><td>password_123</td><td>None</td><td></td><td>None</td></tr></tbody></table>', )
def setUp(self): self.db = None self.cleanfolder() from gluon.globals import current s = Storage({'application': 'welcome', 'folder': 'applications/welcome', 'controller': 'default'}) current.request = s T = TranslatorFactory('', 'en') current.T = T self.db = DAL('sqlite://dummy2.db', check_reserved=['all'])
def __init__(self, mDatabase, mUid, inDGF=True): """Class initialization function :param mDatabase: local database (MoSiVo). :type mDatabase: DAL connection. :param mUid: Mosivo user id. :type inDGF: Integer. :param inDGF: App is in DGF. :type inDGF: Bool. """ # mosivo database self._db = mDatabase # mosivo app user id self._muid = mUid # DGF connection. Please use read only user user='******' passw='' if inDGF: self.rdb = DAL("mssql://%s:%[email protected]/DGF" % (user, passw), migrate_enabled=False, migrate=False) else: self.rdb = DAL('sqlite://dgf_database.db', migrate_enabled=False, migrate=False)
class Dal(object): def __init__(self, table=None, pool_size=8): self.db = DAL(DATABASE_URI, migrate_enabled=False, pool_size=pool_size) if table == 'World': self.db.define_table('World', Field('randomNumber', 'integer')) elif table == 'Fortune': self.db.define_table('Fortune', Field('message')) def get_world(self, wid): # Setting `cacheable=True` improves performance by foregoing the creation # of some non-essential attributes. It does *not* actually cache the # database results (it simply produces a Rows object that *could be* cached). return self.db(self.db.World.id == wid).select(cacheable=True)[0].as_dict() def update_world(self, wid, randomNumber): self.db(self.db.World.id == wid).update(randomNumber=randomNumber) def get_fortunes(self, new_message): fortunes = self.db(self.db.Fortune).select(cacheable=True) fortunes.records.append(Row(new_message)) return fortunes.sort(itemgetter('message'))
def test_IS_IN_DB(self): from gluon.dal import DAL, Field db = DAL('sqlite:memory') db.define_table('person', Field('name')) george_id = db.person.insert(name='george') costanza_id = db.person.insert(name='costanza') rtn = IS_IN_DB(db, 'person.id', '%(name)s')(george_id) self.assertEqual(rtn, (george_id, None)) rtn = IS_IN_DB(db, 'person.id', '%(name)s', error_message='oops')(george_id+costanza_id) self.assertEqual(rtn, (george_id+costanza_id, 'oops')) rtn = IS_IN_DB(db, db.person.id, '%(name)s')(george_id) self.assertEqual(rtn, (george_id, None)) rtn = IS_IN_DB(db, db.person.id, '%(name)s', error_message='oops')(george_id+costanza_id) self.assertEqual(rtn, (george_id+costanza_id, 'oops')) rtn = IS_IN_DB(db, 'person.id', '%(name)s', multiple=True)([george_id,costanza_id]) self.assertEqual(rtn, ([george_id,costanza_id], None)) rtn = IS_IN_DB(db, 'person.id', '%(name)s', multiple=True, delimiter=',')('%d,%d' % (george_id, costanza_id)) self.assertEqual(rtn, ( ('%d,%d' % (george_id, costanza_id)).split(','), None)) rtn = IS_IN_DB(db, db.person.id, '%(name)s', error_message='oops').options(zero=False) self.assertEqual(sorted(rtn), [('%d' % george_id, 'george'), ('%d' % costanza_id, 'costanza')]) db.person.drop()
def _init_log(level=logging.DEBUG): # Create logger: logger=logging.getLogger(request.application) logger.setLevel(level) #sys.path.append(os.path.join(request.folder,'models')) #import dbhandler #handler = dbhandler.DBHandler(db) # INSTANCE 1 #handler = DBHandler(db_instance=db) # INSTANCE 2 db = DAL('mysql://*****:*****@open.cimqzx8oz4zz.us-east-1.rds.amazonaws.com/newDB', pool_size=5, migrate=False) handler = DBHandler(db_instance=db) # INSTANCE 3 #handler = DBHandler(db_url='mysql://*****:*****@open.cimqzx8oz4zz.us-east-1.rds.amazonaws.com/newDB') global MOD_LOG_DB MOD_LOG_DB = DAL('mysql://*****:*****@open.cimqzx8oz4zz.us-east-1.rds.amazonaws.com/newDB', pool_size=0) MOD_LOG_DB.define_table('LOG3',Field('created','string'), migrate=False) global MOD_LOG_SQLITE MOD_LOG_SQLITE = DAL('sqlite://storage.sqlite', pool_size=0) MOD_LOG_SQLITE.define_table('LOG3',Field('created','string'), migrate=False) handler.setLevel(level) logger.addHandler(handler) # Initial log entry: logger.debug("web2py application %s starting" % request.application) # Return logger: return logger
class TestSetup(unittest.TestCase): """docstring for TestSetUp""" def setUp(self): #self.driver = webdriver.Firefox() self.driver = webdriver.Remote(command_executor='http://0.0.0.0:4444/wd/hub', desired_capabilities=DesiredCapabilities.FIREFOX) self.submit_button = "//input[@value='Submit']" db_username_postgres = 'postgres' db_password_postgres = '1234' db_postgres_url = 'postgres://' + db_username_postgres + ':' + db_password_postgres + '@localhost/dev' path_to_database = path.join(path.curdir, "../databases") self.db_test = DAL(db_postgres_url, folder=path_to_database) self.db_test.import_table_definitions(path_to_database) def tearDown(self): self.driver.quit() def submit_form(self): self.driver.find_element_by_xpath(self.submit_button).click() def limpa_dados_tabela(self, nome_tabela): self.db_test.executesql('delete from ' + nome_tabela) self.db_test.commit()
def setUp(self): from gluon.globals import Request, Response, Session, current from gluon.html import A, DIV, FORM, MENU, TABLE, TR, INPUT, URL, XML from gluon.html import ASSIGNJS from gluon.validators import IS_NOT_EMPTY from gluon.compileapp import LOAD from gluon.http import HTTP, redirect from gluon.tools import Auth from gluon.sql import SQLDB from gluon.sqlhtml import SQLTABLE, SQLFORM self.original_check_credentials = fileutils.check_credentials fileutils.check_credentials = fake_check_credentials request = Request(env={}) request.application = 'welcome' request.controller = 'appadmin' request.function = self._testMethodName.split('_')[1] request.folder = 'applications/welcome' request.env.http_host = '127.0.0.1:8000' request.env.remote_addr = '127.0.0.1' response = Response() session = Session() T = translator('', 'en') session.connect(request, response) current.request = request current.response = response current.session = session current.T = T db = DAL(DEFAULT_URI, check_reserved=['all']) auth = Auth(db) auth.define_tables(username=True, signature=False) db.define_table('t0', Field('tt'), auth.signature) # Create a user db.auth_user.insert(first_name='Bart', last_name='Simpson', username='******', email='*****@*****.**', password='******', registration_key=None, registration_id=None) self.env = locals()
def setUp(self): from gluon.globals import Request, Response, Session, current from gluon.html import A, DIV, FORM, MENU, TABLE, TR, INPUT, URL, XML from gluon.html import ASSIGNJS from gluon.validators import IS_NOT_EMPTY from gluon.compileapp import LOAD from gluon.http import HTTP, redirect from gluon.tools import Auth from gluon.sql import SQLDB from gluon.sqlhtml import SQLTABLE, SQLFORM self.original_check_credentials = fileutils.check_credentials fileutils.check_credentials = fake_check_credentials request = Request(env={}) request.application = 'welcome' request.controller = 'appadmin' request.function = self._testMethodName.split('_')[1] request.folder = 'applications/welcome' request.env.http_host = '127.0.0.1:8000' request.env.remote_addr = '127.0.0.1' response = Response() session = Session() T = TranslatorFactory('', 'en') session.connect(request, response) current.request = request current.response = response current.session = session current.T = T db = DAL(DEFAULT_URI, check_reserved=['all']) auth = Auth(db) auth.define_tables(username=True, signature=False) db.define_table('t0', Field('tt'), auth.signature) # Create a user db.auth_user.insert(first_name='Bart', last_name='Simpson', username='******', email='*****@*****.**', password='******', registration_key=None, registration_id=None) self.env = locals()
class TestSQLTABLE(unittest.TestCase): def setUp(self): request = Request(env={}) request.application = 'a' request.controller = 'c' request.function = 'f' request.folder = 'applications/admin' response = Response() session = Session() T = translator('', 'en') session.connect(request, response) from gluon.globals import current current.request = request current.response = response current.session = session current.T = T self.db = DAL(DEFAULT_URI, check_reserved=['all']) self.auth = Auth(self.db) self.auth.define_tables(username=True, signature=False) self.db.define_table('t0', Field('tt'), self.auth.signature) self.auth.enable_record_versioning(self.db) # Create a user self.db.auth_user.insert(first_name='Bart', last_name='Simpson', username='******', email='*****@*****.**', password='******', registration_key=None, registration_id=None) self.db.commit() def test_SQLTABLE(self): rows = self.db(self.db.auth_user.id > 0).select(self.db.auth_user.ALL) sqltable = SQLTABLE(rows) self.assertEqual( sqltable.xml(), '<table><thead><tr><th>auth_user.id</th><th>auth_user.first_name</th><th>auth_user.last_name</th><th>auth_user.email</th><th>auth_user.username</th><th>auth_user.password</th><th>auth_user.registration_key</th><th>auth_user.reset_password_key</th><th>auth_user.registration_id</th></tr></thead><tbody><tr class="w2p_odd odd"><td>1</td><td>Bart</td><td>Simpson</td><td>[email protected]</td><td>user1</td><td>password_123</td><td>None</td><td></td><td>None</td></tr></tbody></table>' )
class Dal(object): def __init__(self, table=None, pool_size=8): self.db = DAL(DATABASE_URI, migrate_enabled=False, pool_size=pool_size) if table == 'World': self.db.define_table('World', Field('randomNumber', 'integer')) elif table == 'Fortune': self.db.define_table('Fortune', Field('message')) def get_world(self, wid): # Setting `cacheable=True` improves performance by foregoing the creation # of some non-essential attributes. It does *not* actually cache the # database results (it simply produces a Rows object that *could be* cached). return self.db(self.db.World.id == wid).select( cacheable=True)[0].as_dict() def update_world(self, wid, randomNumber): self.db(self.db.World.id == wid).update(randomNumber=randomNumber) def get_fortunes(self, new_message): fortunes = self.db(self.db.Fortune).select(cacheable=True) fortunes.records.append(Row(new_message)) return fortunes.sort(itemgetter('message'))
def addChapterInfoUsingDAL(subChapD, chapTitles, course_id): sys.path.insert(0, os.path.join('..', '..', '..')) from gluon.dal import DAL, Field module_path = os.path.abspath(os.path.dirname(__file__)) dbpath = os.path.join(module_path, '..', 'databases') sys.path.insert(0, os.path.join('..', 'models')) _temp = __import__('0', globals(), locals()) settings = _temp.settings execfile(os.path.join('..', 'models', '1.py'), globals(), locals()) db = DAL(settings.database_uri, folder=dbpath, auto_import=False) execfile(os.path.join('..', 'models', 'db_ebook_chapters.py')) addChapterInfoFromScheduler(subChapD, chapTitles, course_id, db)
def toolbar(self): from gluon.html import DIV, SCRIPT, BEAUTIFY, TAG, A BUTTON = TAG.button admin = URL("admin", "default", "design", extension='html', args=current.request.application) from gluon.dal import DAL dbstats = [] dbtables = {} infos = DAL.get_instances() for k, v in iteritems(infos): dbstats.append(TABLE(*[TR(PRE(row[0]), '%.2fms' % (row[1]*1000)) for row in v['dbstats']])) dbtables[k] = dict(defined=v['dbtables']['defined'] or '[no defined tables]', lazy=v['dbtables']['lazy'] or '[no lazy tables]') u = web2py_uuid() backtotop = A('Back to top', _href="#totop-%s" % u) # Convert lazy request.vars from property to Storage so they # will be displayed in the toolbar. request = copy.copy(current.request) request.update(vars=current.request.vars, get_vars=current.request.get_vars, post_vars=current.request.post_vars) return DIV( BUTTON('design', _onclick="document.location='%s'" % admin), BUTTON('request', _onclick="jQuery('#request-%s').slideToggle()" % u), BUTTON('response', _onclick="jQuery('#response-%s').slideToggle()" % u), BUTTON('session', _onclick="jQuery('#session-%s').slideToggle()" % u), BUTTON('db tables', _onclick="jQuery('#db-tables-%s').slideToggle()" % u), BUTTON('db stats', _onclick="jQuery('#db-stats-%s').slideToggle()" % u), DIV(BEAUTIFY(request), backtotop, _class="w2p-toolbar-hidden", _id="request-%s" % u), DIV(BEAUTIFY(current.session), backtotop, _class="w2p-toolbar-hidden", _id="session-%s" % u), DIV(BEAUTIFY(current.response), backtotop, _class="w2p-toolbar-hidden", _id="response-%s" % u), DIV(BEAUTIFY(dbtables), backtotop, _class="w2p-toolbar-hidden", _id="db-tables-%s" % u), DIV(BEAUTIFY(dbstats), backtotop, _class="w2p-toolbar-hidden", _id="db-stats-%s" % u), SCRIPT("jQuery('.w2p-toolbar-hidden').hide()"), _id="totop-%s" % u )
def testSerialization(self): from gluon._compat import pickle db = DAL(check_reserved=['all']) db.define_table('t_a', Field('f_a')) db.t_a.insert(f_a='test') a = db(db.t_a.id > 0).select(cacheable=True) s = pickle.dumps(a) b = pickle.loads(s) self.assertEqual(a.db, b.db) db.t_a.drop() db.close()
def setUp(self): self.tearDown() appdir = os.path.join('applications', test_app_name) os.mkdir(appdir) create_app(appdir) self.db = None from gluon.globals import current s = Storage({'application': test_app_name, 'folder': "applications/%s" % test_app_name, 'controller': 'default'}) current.request = s T = TranslatorFactory('', 'en') current.T = T self.db = DAL('sqlite://dummy2.db', folder="applications/%s/databases" % test_app_name, check_reserved=['all'])
def to_mysql(db, db_old=None): return 'nne none' if not db_old: db_old = DAL( "sqlite://storage.sqlite", # this keyword buil model on fly on load auto_import=True, #folder="../../ipay_db/databases", #folder="/databases", #folder="../../ipay8/databases", folder="applications/ipay8/databases", ) # те таблицы что не надо копировать exept = [ 'orders_stack', 'orders', 'pay_ins', 'pay_ins_stack', 'buys_stack', 'deal_acc_addrs', 'logs' ] for table in db: db[table].truncate() tn = table._tablename if tn in exept: print 'EXEPTED:', table continue print 'CONVERTing:', table for r in db_old(db_old[table]).select(): #if tn == 'deals': print r # заменим зарезервированные слова r_ = dict() for f in r: #print f if f in reserveds: r_[f] = r[f] for f in r_: r[f + '_'] = r_[f] try: db[table][0] = r except Exception as e: print e
def getConnection(self, migrate='disable'): if migrate not in ['fake', 'enable', 'disable']: raise ValueError( 'ConnectionManager.getConnection(): Expected enable|disable|fake in migrate parameter' ) # we are trying up to 10 times because there might be several dead connections in a row for i in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]: try: # last two attempts, without connection pooling db = DAL(self.connectionString, folder=configurator.getPath('db'), \ pool_size = 50 if i < 9 else 0, \ lazy_tables = True if migrate == 'disable' else False, \ migrate_enabled = False if migrate == 'disable' else True, \ fake_migrate_all = True if migrate == 'fake' else False, \ ) break except _mysql_exceptions.OperationalError, err: if err[0] not in [2006 ]: #other exception than [mysql gone away] raise time.sleep(0.2)
def addChapterInfoUsingDAL(subChapD, chapTitles, course_id): sys.path.insert(0, os.path.join('..', '..', '..')) try: from gluon.dal import DAL, Field except ImportError: print "... WARNING ..." print "Cannot Update Chapter and Subchapter Tables in Database" print "Because I am unable to import DAL from web2py" print "In order to update, this application should be installed" print "in the applications folder of a web2py installation" return False module_path = os.path.abspath(os.path.dirname(__file__)) dbpath = os.path.join(module_path, '..', 'databases') sys.path.insert(0, os.path.join('..', 'models')) _temp = __import__('0', globals(), locals()) settings = _temp.settings execfile(os.path.join('..', 'models', '1.py'), globals(), locals()) db = DAL(settings.database_uri, folder=dbpath, auto_import=False) execfile(os.path.join('..', 'models', 'db_ebook_chapters.py')) addChapterInfoFromScheduler(subChapD, chapTitles, course_id, db)
def get_db(): from gluon.dal import DAL return DAL('sqlite://storage.sqlite', auto_import=True)
T.http_accept_language = [ config.LANGUAGE, ] T.requested_languages = [ config.LANGUAGE, ] # force t dictionary load (otherwise translator would overwrite # the language file) T.t = gluon.languages.read_dict(T.language_file) # print "Creating DAL connection" # create DAL connection (and create DB if it does not exists) config.db = DAL(config.DB_URI, folder=config.DATABASES_FOLDER, pool_size=10) # EXPERIMENTAL (imap connection) if config.IMAP_URI: config.imapdb = DAL(config.IMAP_URI) config.imapdb.define_tables() else: config.imapdb = None # Connection example for PostgreSQL database (set this at installation as DB_URI) # or modify the value at [desktopapp]/config.ini and [web2pyapp]/config.ini # specify folder path as webapp path + "databases" # config.db = DAL("postgres://*****:*****@localhost:5432/erplibre", # folder=config.DATABASES_FOLDER)
from gluon.sqlhtml import * from gluon.validators import * # NOTA IMPORTANTE: # Mientras se está en desarrollo, hay que poner migrate=True y lazy_tables=False # para que se puedan crear las tablas necesarias en la base de datos. # Una vez se pase a producción, migrate=False y lazy_tables=True # hará que sea mucho más rápida la ejecución de la aplicación: from gluon import current import datetime from web2pytest import web2pytest is_running_under_test = web2pytest.is_running_under_test(request, request.application) if is_running_under_test: from tempfile import mkdtemp folder = mkdtemp() db = DAL('sqlite://test.sqlite', pool_size=10, check_reserved=['all'], folder=folder) else: db = DAL('sqlite://storage.sqlite', pool_size=1, check_reserved=['all'], migrate=True, lazy_tables=False) current.db = db # by default give a view/generic.extension to all actions from localhost # none otherwise. a pattern can be 'controller/function.extension' response.generic_patterns = (['*'] if request.is_local else []) # (optional) optimize handling of static files # response.optimize_css = 'concat,minify,inline' # response.optimize_js = 'concat,minify,inline'
class TestAuthAPI(unittest.TestCase): def setUp(self): self.request = Request(env={}) self.request.application = 'a' self.request.controller = 'c' self.request.function = 'f' self.request.folder = 'applications/admin' self.response = Response() self.session = Session() T = translator('', 'en') self.session.connect(self.request, self.response) from gluon.globals import current self.current = current self.current.request = self.request self.current.response = self.response self.current.session = self.session self.current.T = T self.db = DAL(DEFAULT_URI, check_reserved=['all']) self.auth = AuthAPI(self.db) self.auth.define_tables(username=True, signature=False) # Create a user self.auth.table_user().validate_and_insert(first_name='Bart', last_name='Simpson', username='******', email='*****@*****.**', password='******', registration_key='', registration_id='') self.db.commit() def test_login(self): result = self.auth.login(**{ 'username': '******', 'password': '******' }) self.assertTrue(self.auth.is_logged_in()) self.assertTrue(result['user']['email'] == '*****@*****.**') self.auth.logout() self.assertFalse(self.auth.is_logged_in()) self.auth.settings.username_case_sensitive = False result = self.auth.login(**{ 'username': '******', 'password': '******' }) self.assertTrue(self.auth.is_logged_in()) def test_logout(self): self.auth.login(**{'username': '******', 'password': '******'}) self.assertTrue(self.auth.is_logged_in()) result = self.auth.logout() self.assertTrue(not self.auth.is_logged_in()) self.assertTrue(result['user'] is None) def test_register(self): self.auth.settings.login_after_registration = True result = self.auth.register( **{ 'username': '******', 'first_name': 'Lisa', 'last_name': 'Simpson', 'email': '*****@*****.**', 'password': '******' }) self.assertTrue(result['user']['email'] == '*****@*****.**') self.assertTrue(self.auth.is_logged_in()) with self.assertRaises( AssertionError): # Can't register if you're logged in result = self.auth.register( **{ 'username': '******', 'first_name': 'Lisa', 'last_name': 'Simpson', 'email': '*****@*****.**', 'password': '******' }) self.auth.logout() self.auth.settings.login_after_registration = False result = self.auth.register( **{ 'username': '******', 'first_name': 'Barney', 'last_name': 'Gumble', 'email': '*****@*****.**', 'password': '******' }) self.assertTrue(result['user']['email'] == '*****@*****.**') self.assertFalse(self.auth.is_logged_in()) self.auth.settings.login_userfield = 'email' result = self.auth.register( **{ 'username': '******', 'first_name': 'Lisa', 'last_name': 'Simpson', 'email': '*****@*****.**', 'password': '******' }) self.assertTrue( result['errors']['email'] == self.auth.messages.email_taken) self.assertTrue(result['user'] is None) self.auth.settings.registration_requires_verification = True result = self.auth.register( **{ 'username': '******', 'first_name': 'Homer', 'last_name': 'Simpson', 'email': '*****@*****.**', 'password': '******' }) self.assertTrue('key' in result['user']) def test_profile(self): with self.assertRaises(AssertionError): # We are not logged in self.auth.profile() self.auth.login(**{'username': '******', 'password': '******'}) self.assertTrue(self.auth.is_logged_in()) result = self.auth.profile(email='*****@*****.**') self.assertTrue(result['user']['email'] == '*****@*****.**') self.assertTrue(self.auth.table_user()[result['user']['id']].email == '*****@*****.**') def test_change_password(self): with self.assertRaises(AssertionError): # We are not logged in self.auth.change_password() self.auth.login(**{'username': '******', 'password': '******'}) self.assertTrue(self.auth.is_logged_in()) self.auth.change_password(old_password='******', new_password='******', new_password2='1234') self.auth.logout() self.assertTrue(not self.auth.is_logged_in()) self.auth.login(username='******', password='******') self.assertTrue(self.auth.is_logged_in()) result = self.auth.change_password(old_password='******', new_password='******', new_password2='5678') self.assertTrue('new_password2' in result['errors']) result = self.auth.change_password(old_password='******', new_password='******', new_password2='1234') self.assertTrue('old_password' in result['errors']) # Test the default 4 min_length is enforced on change password result = self.auth.change_password(old_password='******', new_password='******', new_password2='123') self.assertTrue('new_password' in result['errors']) def test_verify_key(self): self.auth.settings.registration_requires_verification = True result = self.auth.register( **{ 'username': '******', 'first_name': 'Homer', 'last_name': 'Simpson', 'email': '*****@*****.**', 'password': '******' }) self.assertTrue('key' in result['user']) homer_id = result['user']['id'] homers_key = result['user']['key'] result = self.auth.verify_key(key=None) self.assertTrue(result['errors'] is not None) result = self.auth.verify_key(key='12345') self.assertTrue(result['errors'] is not None) result = self.auth.verify_key(key=homers_key) self.assertTrue(result['errors'] is None) self.assertEqual(self.auth.table_user()[homer_id].registration_key, '') self.auth.settings.registration_requires_approval = True result = self.auth.register( **{ 'username': '******', 'first_name': 'Lisa', 'last_name': 'Simpson', 'email': '*****@*****.**', 'password': '******' }) lisa_id = result['user']['id'] result = self.auth.verify_key(key=result['user']['key']) self.assertEqual(self.auth.table_user()[lisa_id].registration_key, 'pending')
class DGFModel(): """This class update all the tables necessary to the simulation """ def __init__(self): """Class initialization function """ # DGF connection. Please use read only user try: if IN_DGF: self.rdb = DAL("mssql://*****:*****@192.168.20.7/DGF", migrate_enabled=False, migrate=False) else: self.rdb = DAL('sqlite://dgf_database.db', migrate_enabled=False, migrate=False) self.session = current.session self.request = current.request self.response = current.response self.cache = current.cache self.__define_tables() print self.rdb.tables() except: print "DGFModel: Can't load database!." def __define_tables(self): """Define all necessary tables in DGF """ self.rdb.define_table('Deptos', Field('Codigo', type='string', length=1), Field('Nombre', type='string'), Field('Numero', type='integer'), primarykey=['Codigo'], migrate=False) self.rdb.define_table( 'Carpetas_P', Field('Codigo', type='integer'), # El numero de la carpeta Field('Nro_Carpeta', type='integer'), Field('Fecha_Pres', type='integer'), # Solo funciona así por el tema de que es un string Field('Cod_Depto', 'reference Deptos.Codigo'), Field('Cod_Sj', type='integer'), Field('Longitud', type='double'), Field('Latitud', type='double'), Field('Baja', type='boolean'), Field('Notas', type='string'), primarykey=['Codigo'], migrate=False) self.rdb.define_table('Plantas', Field('CodG', type='string'), Field('CodE', type='integer'), Field('Genero', type='string'), Field('Especie', type='string'), Field('Descripcion', type='string'), Field('Apel', type='string'), Field('Carac', type='text'), Field('Foto', type='upload'), Field('Taxo', type='upload'), primarykey=['CodG', 'CodE'], migrate=False) self.rdb.define_table( 'Carpetas_BN', Field('Codigo', type='integer'), # El numero de la carpeta Field('Nro_Carpeta', type='integer'), Field('Fecha_pres', type='integer'), Field('Cod_Depto', 'reference Deptos.Codigo'), Field('Cod_Sj', type='integer'), Field('Latitud', type='double'), Field('Longitud', type='double'), Field('Tipo_Bosque', type='string'), Field('Baja', type='boolean'), Field('Notas', type='string'), primarykey=['Codigo'], migrate=False) b = u'Año_Pro' a = b.encode('utf8') self.rdb.define_table( 'Planes_Pro', Field('Codigo', type='integer'), # El numero de la carpeta Carpetas_P(Nro_Carpeta) Field('Codigo_Cp', type='integer'), Field('Fecha_Act', type='datetime'), # RFPV - Esto da lio nombre de campo con caracter especial # Field('Año_Pro', type='integer'), # Field(a,type='integer'), Field('Ano_Pro', type='integer'), Field('CodG_Pro', type='string'), Field('CodE_Pro', type='integer'), Field('Epo_Pro', type='string'), Field('Ha_Pro', type='double'), Field('Den_Pro', type='integer'), Field('E1_Pro', type='integer'), Field('E2_Pro', type='integer'), Field('E3_Pro', type='integer'), Field('Cal_Pro', type='string'), Field('Met_Pro', type='string'), Field('Sem_Pro', type='string'), Field('Planta_Pro', type='string'), Field('Tipo_Planta_Pro', type='string'), Field('Raleo_Pro', type='string'), Field('Poda_Pro', type='string'), Field('Corta_Pro', type='string'), Field('Objetivo_pro', type='string'), Field('Proyecto_g_pro', type='string'), Field('Observaciones', type='string'), primarykey=['Codigo'], migrate=False) self.rdb.define_table( 'Planes', Field('Codigo', type='integer'), # El codigo de Planes_Pro Field('Codigo_Plan_Pro', type='integer'), Field('Fecha_Act', type='datetime'), # RFPV - Esto da lio nombre de campo con caracter especial # Field('Año_Dec', type='integer'), # Field('Ano_Dec', type='integer'), Field('CodG_Dec', type='string'), Field('CodE_Dec', type='integer'), Field('Epo_Dec', type='string'), Field('Ha_Dec', type='double'), Field('Den_Dec', type='integer'), Field('E1_Dec', type='integer'), Field('E2_Dec', type='integer'), Field('E3_Dec', type='integer'), Field('Cal_Dec', type='string'), Field('Met_Dec', type='string'), Field('Sem_Dec', type='string'), Field('Planta_Dec', type='string'), Field('Tipo_Planta_Dec', type='string'), Field('Raleo_Dec', type='string'), Field('Poda_Dec', type='string'), Field('Corta_Dec', type='string'), Field('Objetivo_dec', type='string'), Field('Proyecto_g_dec', type='string'), Field('Observaciones', type='string'), primarykey=['Codigo'], migrate=False) self.rdb.define_table('Propietarios', Field('Codigo', type='integer'), Field('Nombre', type='string'), Field('Direccion', type='string'), Field('Telefono', type='string'), Field('Representacion', type='string'), primarykey=['Codigo'], migrate=False) self.rdb.define_table( 'Registro', Field('Codigo', type='integer'), #Field('Codigo_Cp_Pr',self.rdb.Carpetas_P), #Field('Codigo_Cp_Bn',self.rdb.Carpetas_BN), Field('Codigo_Cp_Pr', type='integer'), Field('Codigo_Cp_Bn', type='integer'), # Solo funciona así por el tema de que es un string Field('Cod_Depto', 'reference Deptos.Codigo'), Field('Codigo_Pad', type='integer'), Field('Anexo', type='string'), Field('Tipo_Bos', type='string'), Field('Cant_Bosques', type='integer'), Field('Cant_Tipo_Bosque', type='integer'), Field('Cant_Tipo_Bosque_Depto', type='integer'), Field('Resoluciones', type='string'), Field('Codigo_Prop', self.rdb.Propietarios), Field('Rep_Prop', type='string'), Field('Area', type='double'), Field('Tipo_Prop', type='string'), primarykey=['Codigo'], migrate=False) def db(self): """ Get the database connection :returns: DAL connection for DGF database """ return (self.rdb)
class TestSQLFORM(unittest.TestCase): def setUp(self): request = Request(env={}) request.application = 'a' request.controller = 'c' request.function = 'f' request.folder = 'applications/admin' response = Response() session = Session() T = translator('', 'en') session.connect(request, response) from gluon.globals import current current.request = request current.response = response current.session = session current.T = T self.db = DAL(DEFAULT_URI, check_reserved=['all']) self.auth = Auth(self.db) self.auth.define_tables(username=True, signature=False) self.db.define_table('t0', Field('tt'), self.auth.signature) self.auth.enable_record_versioning(self.db) # Create a user self.db.auth_user.insert(first_name='Bart', last_name='Simpson', username='******', email='*****@*****.**', password='******', registration_key=None, registration_id=None) self.db.commit() def test_SQLFORM(self): form = SQLFORM(self.db.auth_user) self.assertEqual( form.xml(), '<form action="#" enctype="multipart/form-data" method="post"><table><tr id="auth_user_first_name__row"><td class="w2p_fl"><label class="" for="auth_user_first_name" id="auth_user_first_name__label">First name: </label></td><td class="w2p_fw"><input class="string" id="auth_user_first_name" name="first_name" type="text" value="" /></td><td class="w2p_fc"></td></tr><tr id="auth_user_last_name__row"><td class="w2p_fl"><label class="" for="auth_user_last_name" id="auth_user_last_name__label">Last name: </label></td><td class="w2p_fw"><input class="string" id="auth_user_last_name" name="last_name" type="text" value="" /></td><td class="w2p_fc"></td></tr><tr id="auth_user_email__row"><td class="w2p_fl"><label class="" for="auth_user_email" id="auth_user_email__label">E-mail: </label></td><td class="w2p_fw"><input class="string" id="auth_user_email" name="email" type="text" value="" /></td><td class="w2p_fc"></td></tr><tr id="auth_user_username__row"><td class="w2p_fl"><label class="" for="auth_user_username" id="auth_user_username__label">Username: </label></td><td class="w2p_fw"><input class="string" id="auth_user_username" name="username" type="text" value="" /></td><td class="w2p_fc"></td></tr><tr id="auth_user_password__row"><td class="w2p_fl"><label class="" for="auth_user_password" id="auth_user_password__label">Password: </label></td><td class="w2p_fw"><input class="password" id="auth_user_password" name="password" type="password" value="" /></td><td class="w2p_fc"></td></tr><tr id="submit_record__row"><td class="w2p_fl"></td><td class="w2p_fw"><input type="submit" value="Submit" /></td><td class="w2p_fc"></td></tr></table></form>' ) # def test_assert_status(self): # pass # def test_createform(self): # pass # def test_accepts(self): # pass # def test_dictform(self): # pass # def test_smartdictform(self): # pass def test_factory(self): factory_form = SQLFORM.factory( Field('field_one', 'string', IS_NOT_EMPTY()), Field('field_two', 'string')) self.assertEqual( factory_form.xml(), '<form action="#" enctype="multipart/form-data" method="post"><table><tr id="no_table_field_one__row"><td class="w2p_fl"><label class="" for="no_table_field_one" id="no_table_field_one__label">Field One: </label></td><td class="w2p_fw"><input class="string" id="no_table_field_one" name="field_one" type="text" value="" /></td><td class="w2p_fc"></td></tr><tr id="no_table_field_two__row"><td class="w2p_fl"><label class="" for="no_table_field_two" id="no_table_field_two__label">Field Two: </label></td><td class="w2p_fw"><input class="string" id="no_table_field_two" name="field_two" type="text" value="" /></td><td class="w2p_fc"></td></tr><tr id="submit_record__row"><td class="w2p_fl"></td><td class="w2p_fw"><input type="submit" value="Submit" /></td><td class="w2p_fc"></td></tr></table></form>' ) # def test_build_query(self): # pass # def test_search_menu(self): # pass def test_grid(self): grid_form = SQLFORM.grid(self.db.auth_user) self.assertEqual( grid_form.xml(), '<div class="web2py_grid "><div class="web2py_console "><form action="/a/c/f" enctype="multipart/form-data" method="GET"><input class="form-control" id="w2p_keywords" name="keywords" onfocus="jQuery('#w2p_query_fields').change();jQuery('#w2p_query_panel').slideDown();" type="text" value="" /><input class="btn btn-default" type="submit" value="Search" /><input class="btn btn-default" onclick="jQuery('#w2p_keywords').val('');" type="submit" value="Clear" /></form><div id="w2p_query_panel" style="display:none;"><select class="form-control" id="w2p_query_fields" onchange="jQuery('.w2p_query_row').hide();jQuery('#w2p_field_'+jQuery('#w2p_query_fields').val().replace('.','-')).show();" style="float:left"><option value="auth_user.id">Id</option><option value="auth_user.first_name">First name</option><option value="auth_user.last_name">Last name</option><option value="auth_user.email">E-mail</option><option value="auth_user.username">Username</option></select><div class="w2p_query_row" id="w2p_field_auth_user-id" style="display:none"><select class="form-control"><option value="=">=</option><option value="!=">!=</option><option value="<"><</option><option value=">">></option><option value="<="><=</option><option value=">=">>=</option><option value="in">in</option><option value="not in">not in</option></select><input class="id form-control" id="w2p_value_auth_user-id" type="text" /><input class="btn btn-default" onclick="w2p_build_query('new','auth_user.id')" title="Start building a new search" type="button" value="New Search" /><input class="btn btn-default" onclick="w2p_build_query('and','auth_user.id')" title="Add this to the search as an AND term" type="button" value="+ And" /><input class="btn btn-default" onclick="w2p_build_query('or','auth_user.id')" title="Add this to the search as an OR term" type="button" value="+ Or" /><input class="btn btn-default" onclick="jQuery('#w2p_query_panel').slideUp()" type="button" value="Close" /></div><div class="w2p_query_row" id="w2p_field_auth_user-first_name" style="display:none"><select class="form-control"><option value="=">=</option><option value="!=">!=</option><option value="<"><</option><option value=">">></option><option value="<="><=</option><option value=">=">>=</option><option value="starts with">starts with</option><option value="contains">contains</option><option value="in">in</option><option value="not in">not in</option></select><input class="string form-control" id="w2p_value_auth_user-first_name" type="text" /><input class="btn btn-default" onclick="w2p_build_query('new','auth_user.first_name')" title="Start building a new search" type="button" value="New Search" /><input class="btn btn-default" onclick="w2p_build_query('and','auth_user.first_name')" title="Add this to the search as an AND term" type="button" value="+ And" /><input class="btn btn-default" onclick="w2p_build_query('or','auth_user.first_name')" title="Add this to the search as an OR term" type="button" value="+ Or" /><input class="btn btn-default" onclick="jQuery('#w2p_query_panel').slideUp()" type="button" value="Close" /></div><div class="w2p_query_row" id="w2p_field_auth_user-last_name" style="display:none"><select class="form-control"><option value="=">=</option><option value="!=">!=</option><option value="<"><</option><option value=">">></option><option value="<="><=</option><option value=">=">>=</option><option value="starts with">starts with</option><option value="contains">contains</option><option value="in">in</option><option value="not in">not in</option></select><input class="string form-control" id="w2p_value_auth_user-last_name" type="text" /><input class="btn btn-default" onclick="w2p_build_query('new','auth_user.last_name')" title="Start building a new search" type="button" value="New Search" /><input class="btn btn-default" onclick="w2p_build_query('and','auth_user.last_name')" title="Add this to the search as an AND term" type="button" value="+ And" /><input class="btn btn-default" onclick="w2p_build_query('or','auth_user.last_name')" title="Add this to the search as an OR term" type="button" value="+ Or" /><input class="btn btn-default" onclick="jQuery('#w2p_query_panel').slideUp()" type="button" value="Close" /></div><div class="w2p_query_row" id="w2p_field_auth_user-email" style="display:none"><select class="form-control"><option value="=">=</option><option value="!=">!=</option><option value="<"><</option><option value=">">></option><option value="<="><=</option><option value=">=">>=</option><option value="starts with">starts with</option><option value="contains">contains</option><option value="in">in</option><option value="not in">not in</option></select><input class="string form-control" id="w2p_value_auth_user-email" type="text" /><input class="btn btn-default" onclick="w2p_build_query('new','auth_user.email')" title="Start building a new search" type="button" value="New Search" /><input class="btn btn-default" onclick="w2p_build_query('and','auth_user.email')" title="Add this to the search as an AND term" type="button" value="+ And" /><input class="btn btn-default" onclick="w2p_build_query('or','auth_user.email')" title="Add this to the search as an OR term" type="button" value="+ Or" /><input class="btn btn-default" onclick="jQuery('#w2p_query_panel').slideUp()" type="button" value="Close" /></div><div class="w2p_query_row" id="w2p_field_auth_user-username" style="display:none"><select class="form-control"><option value="=">=</option><option value="!=">!=</option><option value="<"><</option><option value=">">></option><option value="<="><=</option><option value=">=">>=</option><option value="starts with">starts with</option><option value="contains">contains</option><option value="in">in</option><option value="not in">not in</option></select><input class="string form-control" id="w2p_value_auth_user-username" type="text" /><input class="btn btn-default" onclick="w2p_build_query('new','auth_user.username')" title="Start building a new search" type="button" value="New Search" /><input class="btn btn-default" onclick="w2p_build_query('and','auth_user.username')" title="Add this to the search as an AND term" type="button" value="+ And" /><input class="btn btn-default" onclick="w2p_build_query('or','auth_user.username')" title="Add this to the search as an OR term" type="button" value="+ Or" /><input class="btn btn-default" onclick="jQuery('#w2p_query_panel').slideUp()" type="button" value="Close" /></div></div><script><!--\n\n jQuery(\'#w2p_query_fields input,#w2p_query_fields select\').css(\n \'width\',\'auto\');\n jQuery(function(){web2py_ajax_fields(\'#w2p_query_fields\');});\n function w2p_build_query(aggregator,a) {\n var b=a.replace(\'.\',\'-\');\n var option = jQuery(\'#w2p_field_\'+b+\' select\').val();\n var value;\n var $value_item = jQuery(\'#w2p_value_\'+b);\n if ($value_item.is(\':checkbox\')){\n if ($value_item.is(\':checked\'))\n value = \'True\';\n else value = \'False\';\n }\n else\n { value = $value_item.val().replace(\'"\',\'\\\\"\')}\n var s=a+\' \'+option+\' "\'+value+\'"\';\n var k=jQuery(\'#w2p_keywords\');\n var v=k.val();\n if(aggregator==\'new\') k.val(s); else k.val((v?(v+\' \'+ aggregator +\' \'):\'\')+s);\n }\n \n//--></script><div class="web2py_counter">1 records found</div></div><div class="web2py_table"><div class="web2py_htmltable" style="width:100%;overflow-x:auto;-ms-overflow-x:scroll"><table><colgroup><col data-column="1" id="auth_user-id" /><col data-column="2" id="auth_user-first_name" /><col data-column="3" id="auth_user-last_name" /><col data-column="4" id="auth_user-email" /><col data-column="5" id="auth_user-username" /><col data-column="6" /></colgroup><thead><tr class=""><th class=""><a href="/a/c/f?keywords=&order=auth_user.id">Id</a></th><th class=""><a href="/a/c/f?keywords=&order=auth_user.first_name">First name</a></th><th class=""><a href="/a/c/f?keywords=&order=auth_user.last_name">Last name</a></th><th class=""><a href="/a/c/f?keywords=&order=auth_user.email">E-mail</a></th><th class=""><a href="/a/c/f?keywords=&order=auth_user.username">Username</a></th><th class=""></th></tr></thead><tbody><tr class="w2p_odd odd with_id" id="1"><td>1</td><td>Bart</td><td>Simpson</td><td>[email protected]</td><td>user1</td><td class="row_buttons" nowrap="nowrap"><a class="button btn btn-default" href="/a/c/f/view/auth_user/1"><span class="icon magnifier icon-zoom-in glyphicon glyphicon-zoom-in"></span> <span class="buttontext button" title="View">View</span></a></td></tr></tbody></table></div></div><div class="w2p_export_menu">Export:<a class="btn btn-default" href="/a/c/f?_export_type=csv&keywords=&order=" title="Comma-separated export of visible columns. Fields from other tables are exported as they appear on-screen but this may be slow for many rows">CSV</a><a class="btn btn-default" href="/a/c/f?_export_type=csv_with_hidden_cols&keywords=&order=" title="Comma-separated export including columns not shown; fields from other tables are exported as raw values for faster export">CSV (hidden cols)</a><a class="btn btn-default" href="/a/c/f?_export_type=html&keywords=&order=" title="HTML export of visible columns">HTML</a><a class="btn btn-default" href="/a/c/f?_export_type=json&keywords=&order=" title="JSON export of visible columns">JSON</a><a class="btn btn-default" href="/a/c/f?_export_type=tsv&keywords=&order=" title="Spreadsheet-optimised export of tab-separated content, visible columns only. May be slow.">TSV (Spreadsheets)</a><a class="btn btn-default" href="/a/c/f?_export_type=tsv_with_hidden_cols&keywords=&order=" title="Spreadsheet-optimised export of tab-separated content including hidden columns. May be slow">TSV (Spreadsheets, hidden cols)</a><a class="btn btn-default" href="/a/c/f?_export_type=xml&keywords=&order=" title="XML export of columns shown">XML</a></div></div>' ) def test_smartgrid(self): smartgrid_form = SQLFORM.smartgrid(self.db.auth_user) self.assertEqual( smartgrid_form.xml(), '<div class="web2py_grid "><div class="web2py_breadcrumbs"><ul class=""><li class="active w2p_grid_breadcrumb_elem"><a href="/a/c/f/auth_user">Auth users</a></li></ul></div><div class="web2py_console "><form action="/a/c/f/auth_user" enctype="multipart/form-data" method="GET"><input class="form-control" id="w2p_keywords" name="keywords" onfocus="jQuery('#w2p_query_fields').change();jQuery('#w2p_query_panel').slideDown();" type="text" value="" /><input class="btn btn-default" type="submit" value="Search" /><input class="btn btn-default" onclick="jQuery('#w2p_keywords').val('');" type="submit" value="Clear" /></form><div id="w2p_query_panel" style="display:none;"><select class="form-control" id="w2p_query_fields" onchange="jQuery('.w2p_query_row').hide();jQuery('#w2p_field_'+jQuery('#w2p_query_fields').val().replace('.','-')).show();" style="float:left"><option value="auth_user.id">Id</option><option value="auth_user.first_name">First name</option><option value="auth_user.last_name">Last name</option><option value="auth_user.email">E-mail</option><option value="auth_user.username">Username</option></select><div class="w2p_query_row" id="w2p_field_auth_user-id" style="display:none"><select class="form-control"><option value="=">=</option><option value="!=">!=</option><option value="<"><</option><option value=">">></option><option value="<="><=</option><option value=">=">>=</option><option value="in">in</option><option value="not in">not in</option></select><input class="id form-control" id="w2p_value_auth_user-id" type="text" /><input class="btn btn-default" onclick="w2p_build_query('new','auth_user.id')" title="Start building a new search" type="button" value="New Search" /><input class="btn btn-default" onclick="w2p_build_query('and','auth_user.id')" title="Add this to the search as an AND term" type="button" value="+ And" /><input class="btn btn-default" onclick="w2p_build_query('or','auth_user.id')" title="Add this to the search as an OR term" type="button" value="+ Or" /><input class="btn btn-default" onclick="jQuery('#w2p_query_panel').slideUp()" type="button" value="Close" /></div><div class="w2p_query_row" id="w2p_field_auth_user-first_name" style="display:none"><select class="form-control"><option value="=">=</option><option value="!=">!=</option><option value="<"><</option><option value=">">></option><option value="<="><=</option><option value=">=">>=</option><option value="starts with">starts with</option><option value="contains">contains</option><option value="in">in</option><option value="not in">not in</option></select><input class="string form-control" id="w2p_value_auth_user-first_name" type="text" /><input class="btn btn-default" onclick="w2p_build_query('new','auth_user.first_name')" title="Start building a new search" type="button" value="New Search" /><input class="btn btn-default" onclick="w2p_build_query('and','auth_user.first_name')" title="Add this to the search as an AND term" type="button" value="+ And" /><input class="btn btn-default" onclick="w2p_build_query('or','auth_user.first_name')" title="Add this to the search as an OR term" type="button" value="+ Or" /><input class="btn btn-default" onclick="jQuery('#w2p_query_panel').slideUp()" type="button" value="Close" /></div><div class="w2p_query_row" id="w2p_field_auth_user-last_name" style="display:none"><select class="form-control"><option value="=">=</option><option value="!=">!=</option><option value="<"><</option><option value=">">></option><option value="<="><=</option><option value=">=">>=</option><option value="starts with">starts with</option><option value="contains">contains</option><option value="in">in</option><option value="not in">not in</option></select><input class="string form-control" id="w2p_value_auth_user-last_name" type="text" /><input class="btn btn-default" onclick="w2p_build_query('new','auth_user.last_name')" title="Start building a new search" type="button" value="New Search" /><input class="btn btn-default" onclick="w2p_build_query('and','auth_user.last_name')" title="Add this to the search as an AND term" type="button" value="+ And" /><input class="btn btn-default" onclick="w2p_build_query('or','auth_user.last_name')" title="Add this to the search as an OR term" type="button" value="+ Or" /><input class="btn btn-default" onclick="jQuery('#w2p_query_panel').slideUp()" type="button" value="Close" /></div><div class="w2p_query_row" id="w2p_field_auth_user-email" style="display:none"><select class="form-control"><option value="=">=</option><option value="!=">!=</option><option value="<"><</option><option value=">">></option><option value="<="><=</option><option value=">=">>=</option><option value="starts with">starts with</option><option value="contains">contains</option><option value="in">in</option><option value="not in">not in</option></select><input class="string form-control" id="w2p_value_auth_user-email" type="text" /><input class="btn btn-default" onclick="w2p_build_query('new','auth_user.email')" title="Start building a new search" type="button" value="New Search" /><input class="btn btn-default" onclick="w2p_build_query('and','auth_user.email')" title="Add this to the search as an AND term" type="button" value="+ And" /><input class="btn btn-default" onclick="w2p_build_query('or','auth_user.email')" title="Add this to the search as an OR term" type="button" value="+ Or" /><input class="btn btn-default" onclick="jQuery('#w2p_query_panel').slideUp()" type="button" value="Close" /></div><div class="w2p_query_row" id="w2p_field_auth_user-username" style="display:none"><select class="form-control"><option value="=">=</option><option value="!=">!=</option><option value="<"><</option><option value=">">></option><option value="<="><=</option><option value=">=">>=</option><option value="starts with">starts with</option><option value="contains">contains</option><option value="in">in</option><option value="not in">not in</option></select><input class="string form-control" id="w2p_value_auth_user-username" type="text" /><input class="btn btn-default" onclick="w2p_build_query('new','auth_user.username')" title="Start building a new search" type="button" value="New Search" /><input class="btn btn-default" onclick="w2p_build_query('and','auth_user.username')" title="Add this to the search as an AND term" type="button" value="+ And" /><input class="btn btn-default" onclick="w2p_build_query('or','auth_user.username')" title="Add this to the search as an OR term" type="button" value="+ Or" /><input class="btn btn-default" onclick="jQuery('#w2p_query_panel').slideUp()" type="button" value="Close" /></div></div><script><!--\n\n jQuery(\'#w2p_query_fields input,#w2p_query_fields select\').css(\n \'width\',\'auto\');\n jQuery(function(){web2py_ajax_fields(\'#w2p_query_fields\');});\n function w2p_build_query(aggregator,a) {\n var b=a.replace(\'.\',\'-\');\n var option = jQuery(\'#w2p_field_\'+b+\' select\').val();\n var value;\n var $value_item = jQuery(\'#w2p_value_\'+b);\n if ($value_item.is(\':checkbox\')){\n if ($value_item.is(\':checked\'))\n value = \'True\';\n else value = \'False\';\n }\n else\n { value = $value_item.val().replace(\'"\',\'\\\\"\')}\n var s=a+\' \'+option+\' "\'+value+\'"\';\n var k=jQuery(\'#w2p_keywords\');\n var v=k.val();\n if(aggregator==\'new\') k.val(s); else k.val((v?(v+\' \'+ aggregator +\' \'):\'\')+s);\n }\n \n//--></script><div class="web2py_counter">1 records found</div></div><div class="web2py_table"><div class="web2py_htmltable" style="width:100%;overflow-x:auto;-ms-overflow-x:scroll"><table><colgroup><col data-column="1" id="auth_user-id" /><col data-column="2" id="auth_user-first_name" /><col data-column="3" id="auth_user-last_name" /><col data-column="4" id="auth_user-email" /><col data-column="5" id="auth_user-username" /><col data-column="6" /></colgroup><thead><tr class=""><th class=""><a href="/a/c/f/auth_user?keywords=&order=auth_user.id">Id</a></th><th class=""><a href="/a/c/f/auth_user?keywords=&order=auth_user.first_name">First name</a></th><th class=""><a href="/a/c/f/auth_user?keywords=&order=auth_user.last_name">Last name</a></th><th class=""><a href="/a/c/f/auth_user?keywords=&order=auth_user.email">E-mail</a></th><th class=""><a href="/a/c/f/auth_user?keywords=&order=auth_user.username">Username</a></th><th class=""></th></tr></thead><tbody><tr class="w2p_odd odd with_id" id="1"><td>1</td><td>Bart</td><td>Simpson</td><td>[email protected]</td><td>user1</td><td class="row_buttons" nowrap="nowrap"><a href="/a/c/f/auth_user/auth_membership.user_id/1"><span>Auth memberships</span></a><a href="/a/c/f/auth_user/auth_event.user_id/1"><span>Auth events</span></a><a href="/a/c/f/auth_user/auth_cas.user_id/1"><span>Auth cases</span></a><a href="/a/c/f/auth_user/t0.created_by/1"><span>T0s(created_by)</span></a><a href="/a/c/f/auth_user/t0.modified_by/1"><span>T0s(modified_by)</span></a><a href="/a/c/f/auth_user/t0_archive.created_by/1"><span>T0 archives(created_by)</span></a><a href="/a/c/f/auth_user/t0_archive.modified_by/1"><span>T0 archives(modified_by)</span></a><a class="button btn btn-default" href="/a/c/f/auth_user/view/auth_user/1"><span class="icon magnifier icon-zoom-in glyphicon glyphicon-zoom-in"></span> <span class="buttontext button" title="View">View</span></a></td></tr></tbody></table></div></div><div class="w2p_export_menu">Export:<a class="btn btn-default" href="/a/c/f/auth_user?_export_type=csv&keywords=&order=" title="Comma-separated export of visible columns. Fields from other tables are exported as they appear on-screen but this may be slow for many rows">CSV</a><a class="btn btn-default" href="/a/c/f/auth_user?_export_type=csv_with_hidden_cols&keywords=&order=" title="Comma-separated export including columns not shown; fields from other tables are exported as raw values for faster export">CSV (hidden cols)</a><a class="btn btn-default" href="/a/c/f/auth_user?_export_type=html&keywords=&order=" title="HTML export of visible columns">HTML</a><a class="btn btn-default" href="/a/c/f/auth_user?_export_type=json&keywords=&order=" title="JSON export of visible columns">JSON</a><a class="btn btn-default" href="/a/c/f/auth_user?_export_type=tsv&keywords=&order=" title="Spreadsheet-optimised export of tab-separated content, visible columns only. May be slow.">TSV (Spreadsheets)</a><a class="btn btn-default" href="/a/c/f/auth_user?_export_type=tsv_with_hidden_cols&keywords=&order=" title="Spreadsheet-optimised export of tab-separated content including hidden columns. May be slow">TSV (Spreadsheets, hidden cols)</a><a class="btn btn-default" href="/a/c/f/auth_user?_export_type=xml&keywords=&order=" title="XML export of columns shown">XML</a></div></div>' )
# if SSL/HTTPS is properly configured and you want all HTTP requests to # be redirected to HTTPS, uncomment the line below: # request.requires_https() """ if current.request.is_local: from gluon.custom_import import track_changes track_changes() def check_path(path): if os.path.exists(path): return path raise OSError(2, "{}: {}".format(os.strerror(2), path)) db = DAL('sqlite://storage.sqlite', fake_migrate=False, migrate=True) current.db = db # by default give a view/generic.extension to all actions from localhost # none otherwise. a pattern can be 'controller/function.extension' response.generic_patterns = ['*'] if request.is_local else [] # (optional) optimize handling of static files # response.optimize_css = 'concat,minify,inline' # response.optimize_js = 'concat,minify,inline' # ------------------------------------------------------------- # get private data from secure file # ------------------------------------------------------------- keydata = {} with open('applications/grammateus3/private/app.keys', 'r') as keyfile: for line in keyfile: