def DefineTermStatsTables(self): self.db.define_table('term_texts', Field('term_index', 'integer', required=True, unique=True, default=-1), Field('term_text', 'string', required=True, unique=True), migrate=self.isInit) if self.isInit: self.db.executesql( 'CREATE INDEX IF NOT EXISTS term_text_value ON term_texts (term_text);' ) self.db.define_table('term_freqs', Field('term_index', 'integer', required=True, unique=True, default=-1), Field('value', 'double', required=True), Field('rank', 'integer', required=True), migrate=self.isInit) if self.isInit: self.db.executesql( 'CREATE INDEX IF NOT EXISTS term_freqs_value ON term_freqs (value);' ) self.db.executesql( 'CREATE INDEX IF NOT EXISTS term_freqs_rank ON term_freqs (rank);' ) self.db.define_table('term_probs', Field('term_index', 'integer', required=True, unique=True, default=-1), Field('value', 'double', required=True), Field('rank', 'integer', required=True), migrate=self.isInit) if self.isInit: self.db.executesql( 'CREATE INDEX IF NOT EXISTS term_probs_value ON term_probs (value);' ) self.db.executesql( 'CREATE INDEX IF NOT EXISTS term_probs_rank ON term_probs (rank);' ) self.db.define_table('term_doc_freqs', Field('term_index', 'integer', required=True, unique=True, default=-1), Field('value', 'double', required=True), Field('rank', 'integer', required=True), migrate=self.isInit) if self.isInit: self.db.executesql( 'CREATE INDEX IF NOT EXISTS term_doc_freqs_value ON term_doc_freqs (value);' ) self.db.executesql( 'CREATE INDEX IF NOT EXISTS term_doc_freqs_rank ON term_doc_freqs (rank);' )
def DefineModelsTable(self): self.db.define_table( 'models', Field( 'model_key' , 'string', required = True, unique = True ), Field( 'model_desc', 'string', required = True ), migrate = self.isInit )
from gluon import fileutils from gluon.http import * from gluon.sqlhtml import * from gluon.tools import fetch import datetime from datetime import timedelta from datetime import date # configuration = AppConfig() db = DAL('sqlite://storage.sqlite') MIGRATE_SETTING = False db.define_table("admins", Field("administrator"), Field("admin_key", "password"), migrate=MIGRATE_SETTING) db.define_table("id_refs", Field("classroom_id_ref", default="0"), Field("quiz_id_ref", default="0"), Field("quiz_question_id_ref", default="0"), Field("student_id_ref", default="0"), Field("teacher_id_ref", default="0"), migrate=MIGRATE_SETTING) db.define_table("teachers", Field("teacher_id"), Field("name"), Field("handle"), Field("portal_pswd", "password"), migrate=MIGRATE_SETTING)
def DefineDimensionTables(self): self.db.define_table('terms', Field('term_index', 'integer', required=True, unique=True, default=-1), Field('term_text', 'string', required=True, unique=True), Field('term_freq', 'double', required=True), Field('rank', 'integer', required=True), migrate=self.isInit) if self.isInit: self.db.executesql( 'CREATE UNIQUE INDEX IF NOT EXISTS terms_index ON terms (term_index);' ) self.db.executesql( 'CREATE UNIQUE INDEX IF NOT EXISTS terms_text ON terms (term_text);' ) self.db.executesql( 'CREATE INDEX IF NOT EXISTS terms_freq ON terms (term_freq);' ) self.db.executesql( 'CREATE INDEX IF NOT EXISTS terms_rank ON terms (rank);' ) self.db.define_table('docs', Field('doc_index', 'integer', required=True, unique=True, default=-1), Field('doc_id', 'string', required=True, unique=True), Field('doc_freq', 'double', required=True), Field('rank', 'integer', required=True), migrate=self.isInit) if self.isInit: self.db.executesql( 'CREATE UNIQUE INDEX IF NOT EXISTS docs_index ON docs (doc_index);' ) self.db.executesql( 'CREATE UNIQUE INDEX IF NOT EXISTS docs_id ON docs (doc_id);' ) self.db.executesql( 'CREATE INDEX IF NOT EXISTS docs_freq ON docs (doc_freq);' ) self.db.executesql( 'CREATE INDEX IF NOT EXISTS docs_rank ON docs (rank);') self.db.define_table('topics', Field('topic_index', 'integer', required=True, unique=True, default=-1), Field('topic_freq', 'double', required=True), Field('topic_label', 'string', required=True), Field('topic_desc', 'string', required=True), Field('top_terms', 'list:integer', required=True), Field('top_docs', 'list:integer', required=True), Field('rank', 'integer', required=True), migrate=self.isInit) if self.isInit: self.db.executesql( 'CREATE UNIQUE INDEX IF NOT EXISTS topics_index ON topics (topic_index);' ) self.db.executesql( 'CREATE INDEX IF NOT EXISTS topics_freq ON topics (topic_freq);' ) self.db.executesql( 'CREATE INDEX IF NOT EXISTS topics_rank ON topics (rank);' )
def DefineSentenceCoStatsTables(self): self.db.define_table('sentences_co_freqs', Field('first_term_index', 'integer', required=True, default=-1), Field('second_term_index', 'integer', required=True, default=-1), Field('value', 'double', required=True), Field('rank', 'integer', required=True), migrate=self.isInit) if self.isInit: self.db.executesql( 'CREATE UNIQUE INDEX IF NOT EXISTS sentences_co_freqs_indexes ON sentences_co_freqs (first_term_index, second_term_index);' ) self.db.executesql( 'CREATE INDEX IF NOT EXISTS sentences_co_freqs_value ON sentences_co_freqs (value);' ) self.db.executesql( 'CREATE INDEX IF NOT EXISTS sentences_co_freqs_rank ON sentences_co_freqs (rank);' ) self.db.define_table('sentences_co_probs', Field('first_term_index', 'integer', required=True, default=-1), Field('second_term_index', 'integer', required=True, default=-1), Field('value', 'double', required=True), Field('rank', 'integer', required=True), migrate=self.isInit) if self.isInit: self.db.executesql( 'CREATE UNIQUE INDEX IF NOT EXISTS sentences_co_probs_indexes ON sentences_co_probs (first_term_index, second_term_index);' ) self.db.executesql( 'CREATE INDEX IF NOT EXISTS sentences_co_probs_value ON sentences_co_probs (value);' ) self.db.executesql( 'CREATE INDEX IF NOT EXISTS sentences_co_probs_rank ON sentences_co_probs (rank);' ) self.db.define_table('sentences_pmi', Field('first_term_index', 'integer', required=True, default=-1), Field('second_term_index', 'integer', required=True, default=-1), Field('value', 'double', required=True), Field('rank', 'integer', required=True), migrate=self.isInit) if self.isInit: self.db.executesql( 'CREATE UNIQUE INDEX IF NOT EXISTS sentences_pmi_indexes ON sentences_pmi (first_term_index, second_term_index);' ) self.db.executesql( 'CREATE INDEX IF NOT EXISTS sentences_pmi_value ON sentences_pmi (value);' ) self.db.executesql( 'CREATE INDEX IF NOT EXISTS sentences_pmi_rank ON sentences_pmi (rank);' ) self.db.define_table('sentences_g2', Field('first_term_index', 'integer', required=True, default=-1), Field('second_term_index', 'integer', required=True, default=-1), Field('value', 'double', required=True), Field('rank', 'integer', required=True), migrate=self.isInit) if self.isInit: self.db.executesql( 'CREATE UNIQUE INDEX IF NOT EXISTS sentences_g2_indexes ON sentences_g2 (first_term_index, second_term_index);' ) self.db.executesql( 'CREATE INDEX IF NOT EXISTS sentences_g2_value ON sentences_g2 (value);' ) self.db.executesql( 'CREATE INDEX IF NOT EXISTS sentences_g2_rank ON sentences_g2 (rank);' )
return FORM(SELECT( _id="translate", _onchange="document.location='%s?_language='+jQuery(this).val()" \ % URL(r=request,args=request.args), value=session._language, *[OPTION(k,_value=v) for v,k in languages])) def createTable(table): query = db._adapter.create_table(table, migrate=False, fake_migrate=False) db._adapter.create_sequence_and_triggers(query, table) db.commit() table = db.define_table( 'settings', Field('id', readable=False, writable=False), Field('fieldname', type='string', label=T('FieldName'), length=150, notnull=True, required=True, unique=True), Field('value', type='string', label=T('Value'), length=255), Field('description', type='text', label=T('Description')), Field('deleted', type='boolean', label=T('Deleted'), default=False, notnull=True, readable=False,
INPUT(_type='checkbox', _name='myvar', _width="10%"), LABEL("check1", _width="65%"), LABEL("", _width="25%"), INPUT(_type='checkbox', _name='myvar', _width="10%"), LABEL("check1", _width="65%"), LABEL("", _width="25%"), INPUT(_type='checkbox', _name='myvar', _width="10%"), LABEL("check1", _width="65%"), TEXTAREA("hola!", _name='mytextarea', _width="100%"), "hola3!", INPUT(_type='submit', _name='submit'), ) elif '--sqlform' in sys.argv: form = SQLFORM.factory( Field("test", "string", requires=IS_NOT_EMPTY(), comment="some data"), Field("test1", "string", requires=IS_NOT_EMPTY(), comment="some data"), Field("test2", "string", requires=IS_NOT_EMPTY(), comment="some data"), Field("test3", "string", requires=IS_NOT_EMPTY(), comment="some data"), formname=None, )
def reports(): response.subtitle = T("Report templates") response.view = 'nas/reports.html' response.cmd_back = ui.control.get_mobil_button( label=T("Account"), href=URL("account", **{'user_signature': True}), icon="back", ajax="false", theme="a", mini="true") nas_reports = ntool.getReportFiles( os.path.join(ns.request.folder, 'static/resources/report')) frm_filter = SQLFORM.factory( Field('database', db.databases, requires=IS_IN_DB(db((db.databases.deleted == False)), db.databases.id, '%(alias)s'), label=T('Database')), Field('reptype', "string", label=T('Rep.type'), requires=IS_EMPTY_OR(IS_IN_SET(nas_reports["types"]))), Field('label', "string", label=T('Group'), requires=IS_EMPTY_OR(IS_IN_SET(nas_reports["labels"]))), Field('repname', type='string', length=50, label=T('Name/Description')), Field('install', type='boolean', label=T('Installed')), submit_button=T("Load"), table_name="filter", _id="frm_filter") if request.post_vars.has_key("report_labels"): if ns.local.setEngine( database=db.databases(id=request.post_vars["database"]).alias, check_ndi=False, created=False, createdb=False): for label_id in request.post_vars.keys(): if label_id not in ("report_labels", "database"): row_id = ns.connect.updateData( "ui_message", values={ "id": label_id, "msg": request.post_vars[label_id] }, validate=False, insert_row=False) if not row_id: response.flash = str(ns.error_message) ns.db.commit() if session.frm_filter: frm_filter.vars = session.frm_filter else: response.flash = str(ns.error_message) if request.post_vars.has_key("ins_cmd"): if ns.local.setEngine(database=db.databases( id=request.post_vars["ins_database"]).alias, check_ndi=False, created=False, createdb=False): if request.post_vars["ins_cmd"] == "delete": try: report_id = ns.db.ui_report( reportkey=request.post_vars["ins_reportkey"])["id"] ns.db( ns.db.ui_reportfields.report_id == report_id).delete() ns.db(ns.db.ui_reportsources.report_id == report_id).delete() ns.db((ns.db.ui_message.secname.like( request.post_vars["ins_reportkey"] + "%"))).delete() ns.db(ns.db.ui_report.id == report_id).delete() ns.db.commit() except Exception, err: response.flash = str(err) else: load = dbtool.loadReport( fileName=request.post_vars["ins_reportkey"] + ".xml") if load != "OK": response.flash = load if session.frm_filter: frm_filter.vars = session.frm_filter else: response.flash = str(ns.error_message)