Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- git_repo/
- venv/
- project/ - All actual Python resides in here
- __init__.py
- ui/
- static/ - Static Flask stuff
- templates/ - HTML templates
- __init__.py
- db.py
- user.py
- views.py
- dev_server.py - Simple entry point for UI dev (i.e. `app.run()`)
- ...
- import flask
- import project
- app = flask.Flask(__name__)
- <snip> Some logging setup, Flask config, etc. </snip>
- import project.ui.views
- import os
- import peewee
- import project
- from project.ui import app
- ui_db = os.path.join(project.dir, 'db.db')
- class Model(peewee.Model):
- class Meta:
- database = ui_db
- import peewee
- import project.ui.db
- class User(project.ui.db.Model):
- username = peewee.CharField(unique=True)
- password = peewee.CharField()
- name = peewee.CharField()
- def get_user(username):
- try:
- return User.select().where(User.username == username)
- except peewee.DoesNotExist:
- return None
- def check_user(username, password):
- u = get_user(username)
- if u:
- return u.password == password
- return False
- import flask
- from project.ui import app
- import project.ui.user
- @app.route('/login', methods=['GET', 'POST'])
- def route_login():
- # Do some stuff using project.ui.user (User, get_user and check_user)
- ...
- # Other routes, etc
- ...
- File ".../project/ui/user.py", line 5, in <module>
- class User(project.ui.db.Model):
- AttributeError: module 'project' has no attribute 'ui'
Add Comment
Please, Sign In to add comment