本文整理汇总了Python中models.initialize函数的典型用法代码示例。如果您正苦于以下问题:Python initialize函数的具体用法?Python initialize怎么用?Python initialize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了initialize函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setup_database
def setup_database():
""" Initialize the database file, maybe drop all tables. """
# -------------------------------------------------------------------------
# Set up the database.
# -------------------------------------------------------------------------
# !!AI uncomment me when needed.
#models.drop_all()
models.initialize()
示例2: setUp
def setUp(self):
"""Runs before every test, creating the User table and
one entry if either are not present"""
# Opens connection, creates table, and closes connection
models.initialize()
# Creates one mock entry in the database
models.User.create_user(username='testUsername',
email='[email protected]',
password='testPassword')
# Retrieves mock entry from database and stores it locally
self.user = models.User.get(email='[email protected]')
示例3: init
def init():
db_session = DBSession()
system_version = SystemVersion.get(db_session)
# Handles database schema migration
for version in range(system_version.schema_version, CURRENT_SCHEMA_VERSION+1):
handler_class = get_schema_migrate_class(version)
if handler_class is not None:
try:
handler_class(version).execute()
except:
print(traceback.format_exc())
# Initialize certain tables
initialize()
示例4: __init__
def __init__(self, db_name, encrypter=None, store_text=True):
self.session_maker = models.initialize(db_name)
self.session = None
models.ENCRYPTER = encrypter
self.store_text = store_text
self.nrmoves = 0
self.latestx = 0
self.latesty = 0
self.lastspecial = None
self.specials_in_row = 0
self.curtext = u""
self.key_presses = []
self.last_key_time = time.time()
self.started = NOW()
self.cur_class = None
self.cur_window = None
self.cur_name = None
self.cur_process_id = None
self.cur_win_id = None
self.cur_win_proc = None
示例5: index
def index():
return 'Hey'
if __name__ == '__main__':
models.initialize()
try:
models.User.create_user(
username='juliancruz',
email='[email protected]',
password='password',
admin=True
)
except ValueError:
pass
app.run(debug=DEBUG, host=HOST, port=PORT)
示例6: init
def init():
db_session = DBSession()
system_version = SystemVersion.get(db_session)
# Handles database schema migration starting from the next schema version
for version in range(system_version.schema_version + 1, CURRENT_SCHEMA_VERSION + 1):
handler_class = get_schema_migrate_class(version)
if handler_class is not None:
try:
handler_class(version).execute()
except:
print(traceback.format_exc())
apply_dialect_specific_codes()
# Initialize certain tables
initialize()
示例7: init
def init():
if not is_ldap_supported():
print('LDAP authentication is not supported because it has not been installed.')
db_session = DBSession()
system_version = SystemVersion.get(db_session)
# Handles database schema migration starting from the next schema version
for version in range(system_version.schema_version + 1, CURRENT_SCHEMA_VERSION + 1):
handler_class = get_schema_migrate_class(version)
if handler_class is not None:
try:
handler_class(version).execute()
except:
print(traceback.format_exc())
# Initialize certain tables
initialize()
示例8: __init__
def __init__(self, db_name, encrypter=None, store_text=True):
self.session_maker = models.initialize(db_name)
models.ENCRYPTER = encrypter
self.store_text = store_text
self.curtext = u""
self.key_presses = []
self.mouse_path = []
self.current_window = Display()
self.last_key_time = time.time()
self.started = NOW()
示例9: flash
try:
user = models.User.get(models.User.email == form.email.data)
except models.DoesNotExist:
flash("Your email or password doesn't match.", "error")
else:
if check_password_hash(user.password, form.password.data):
login_user(user)
flash("You've been logged in!", "success")
return redirect(url_for('index'))
else:
flash("Your email or password doesn't match.", "error")
return render_template('login.html', form = form)
@app.route('/')
def index():
return 'Hey'
if __name__ == '__main__':
models.initialize()
try:
models.User.create_user(
username = 'fionarowan',
email = '[email protected]',
password = 'password',
admin=True
)
except ValueError:
pass
app.run(debug=DEBUG, host = HOST, port = PORT)
示例10: Database
#!/usr/bin/env python
from database import MDB as Database
from config import dbconf, bsconf
from models import *
import models
if __name__ == "__main__":
database = Database(**dbconf)
blobstore = None # Blobstore(bsconf.nodes, **bsconf.opts)
models.initialize(database, blobstore)
database.create_tables([
User,
Token,
Repo,
HMap,
CSet,
Blob,
CommitMessage
], safe=True)
示例11: __init__
def __init__(self, db_name, args):
self.args = args
self.session_maker = models.initialize(db_name)
self.inmouse = False
self.check_needs()
示例12: logout
@login_required
def logout():
logout_user()
return redirect(url_for("index"))
@app.route("/taco", methods=('GET', 'POST'))
@login_required
def taco():
form = TacoForm()
if form.validate_on_submit():
Taco.create(
protein=form.protein.data,
shell=form.shell.data,
cheese=form.cheese.data,
extras=form.extras.data,
user=current_user._get_current_object()
)
return redirect(url_for("index"))
return render_template("taco.html", form=form)
@app.route("/")
def index():
return render_template("index.html", tacos=Taco.select())
if __name__ == "__main__":
initialize()
app.run(port=8000,debug=True, host="localhost")
示例13: define
from database import PooledMDB as Database
import tornado.httpserver
import tornado.ioloop
import tornado.options
import tornado.web
from tornado.options import define, options
define("port", default=5000, help="port to bind to", type=int)
from config import settings, dbconf, bsconf
from routes import routes
import models
class Application(tornado.web.Application):
def __init__(self, dbconf, bsconf, handlers=None, **settings):
super(Application, self).__init__(handlers, **settings)
self.blobstore = None # Blobstore(bsconf.nodes, **bsconf.opts)
self.database = Database(stale_timeout=599, **dbconf)
if __name__ == "__main__":
tornado.options.parse_command_line()
app = Application(dbconf, bsconf, routes, **settings)
models.initialize(app.database, app.blobstore)
server = tornado.httpserver.HTTPServer(app)
server.listen(tornado.options.options.port)
tornado.ioloop.IOLoop.instance().start()
示例14: flash
else:
flash('You have unfollowing {}!'.format(to_user.username), 'alert-success')
return redirect(url_for('stream', username=to_user.username))
@app.errorhandler(404) # error handeling view function
def not_found(error):
return render_template('404.html'), 404
if __name__ == '__main__': # launching our falsk application
models.initialize() # initializing our models in the database
try:
models.User.create_user(username='athoug', email='[email protected]', password='password', name='Athoug Alsoughayer', department='CS') # for testing purposes
except ValueError:
pass
app.run(debug=DEBUG)