Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """The application's model objects"""
- import sqlalchemy as sa
- from sqlalchemy.ext.declarative import declarative_base
- from sqlalchemy.orm import synonym
- from mangas.model import meta
- from hashlib import sha224
- def init_model(engine):
- """Call me before using any of the tables or classes in the model"""
- ## Reflected tables must be defined and mapped here
- #global reflected_table
- #reflected_table = sa.Table("Reflected", meta.metadata, autoload=True,
- # autoload_with=engine)
- #orm.mapper(Reflected, reflected_table)
- #
- meta.Session.configure(bind=engine)
- meta.engine = engine
- _Base = declarative_base(metadata=meta)
- class Users(_Base):
- __tablename__ = 'users'
- id = sa.Column("id", sa.types.Integer, primary_key=True)
- username = sa.Column("username", sa.types.Unicode(20), nullable=False)
- email = sa.Column("email", sa.types.Unicode(100), nullable=False)
- _password = sa.Column("password", sa.types.Unicode(64), nullable=False)
- def _set_password(self, password):
- hashed_password = sha224(password.encode('UTF-8')).hexdigest()
- if not isinstance(hashed_password, unicode):
- hashed_password = hashed_password.decode('UTF-8')
- self._password = hashed_password
- def _get_password(self):
- return _password
- password = synonym('_password', descriptor=property(_get_password, _set_password))
- def validate_password(self, password):
- hashed_password = sha224(password.encode('UTF-8')).hexdigest()
- return self.password == hashed_password
- Traceback (most recent call last):
- File "/usr/local/bin/paster", line 8, in <module>
- load_entry_point('PasteScript==1.7.3', 'console_scripts', 'paster')()
- File "/Library/Python/2.6/site-packages/PasteScript-1.7.3-py2.6.egg/paste/script/command.py", line 84, in run
- invoke(command, command_name, options, args[1:])
- File "/Library/Python/2.6/site-packages/PasteScript-1.7.3-py2.6.egg/paste/script/command.py", line 123, in invoke
- exit_code = runner.run(args)
- File "/Library/Python/2.6/site-packages/PasteScript-1.7.3-py2.6.egg/paste/script/appinstall.py", line 68, in run
- return super(AbstractInstallCommand, self).run(new_args)
- File "/Library/Python/2.6/site-packages/PasteScript-1.7.3-py2.6.egg/paste/script/command.py", line 218, in run
- result = self.command()
- File "/Library/Python/2.6/site-packages/PasteScript-1.7.3-py2.6.egg/paste/script/appinstall.py", line 447, in command
- conf = appconfig(config_spec, relative_to=os.getcwd())
- File "/Library/Python/2.6/site-packages/PasteDeploy-1.3.3-py2.6.egg/paste/deploy/loadwsgi.py", line 215, in appconfig
- global_conf=global_conf)
- File "/Library/Python/2.6/site-packages/PasteDeploy-1.3.3-py2.6.egg/paste/deploy/loadwsgi.py", line 248, in loadcontext
- global_conf=global_conf)
- File "/Library/Python/2 File "/Library/Python/2 File "/Library/Python/2 File "/Library/Python/2.6/site-packages/PasteDeploy-1.3.3-py2.6.egg/paste/deploy/loadwsgi.py", line 278, in _loadconfig
- return loader.get_context(object_type, name, global_conf)
- File "/Library/Python/2.6/site-packages/PasteDeploy-1.3.3-py2.6.egg/paste/deploy/loadwsgi.py", line 409, in get_context
- section)
- File "/Library/Python/2.6/site-packages/PasteDeploy-1.3.3-py2.6.egg/paste/deploy/loadwsgi.py", line 431, in _context_from_use
- object_type, name=use, global_conf=global_conf)
- File "/Library/Python/2.6/site-packages/PasteDeploy-1.3.3-py2.6.egg/paste/deploy/loadwsgi.py", line 361, in get_context
- global_conf=global_conf)
- File "/Library/Python/2.6/site-packages/PasteDeploy-1.3.3-py2.6.egg/paste/deploy/loadwsgi.py", line 248, in loadcontext
- global_conf=global_conf)
- File "/Library/Python/2.6/site-packages/PasteDeploy-1.3.3-py2.6.egg/paste/deploy/loadwsgi.py", line 285, in _loadegg
- return loader.get_context(object_type, name, global_conf)
- File "/Library/Python/2.6/site-packages/PasteDeploy-1.3.3-py2.6.egg/paste/deploy/loadwsgi.py", line 561, in get_context
- object_type, name=name)
- File "/Library/Python/2.6/site-packages/PasteDeploy-1.3.3-py2.6.egg/paste/deploy/loadwsgi.py", line 587, in find_egg_entry_point
- possible.append((entry.load(), protocol, entry.name))
- File "/Library/Python/2.6/site-packages/setuptools-0.6c11-py2.6.egg/pkg_resources.py", line 1954, in load
- File "/Users/francescom/Documents/Dev/mangas/mangas/config/middleware.py", line 12, in <module>
- from mangas.config.environment import load_environment
- File "/Users/francescom/Documents/Dev/mangas/mangas/config/environment.py", line 12, in <module>
- from mangas.model import init_model
- File "/Users/francescom/Documents/Dev/mangas/mangas/model/__init__.py", line 23, in <module>
- class Users(_Base):
- File "/Library/Python/2.6/site-packages/SQLAlchemy-0.5.8-py2.6.egg/sqlalchemy/ext/declarative.py", line 561, in __init__
- _as_declarative(cls, classname, dict_)
- File "/Library/Python/2.6/site-packages/SQLAlchemy-0.5.8-py2.6.egg/sqlalchemy/ext/declarative.py", line 494, in _as_declarative
- *(tuple(cols) + tuple(args)), **table_kw)
- File "/Library/Python/2.6/site-packages/SQLAlchemy-0.5.8-py2.6.egg/sqlalchemy/schema.py", line 94, in __call__
- table = metadata.tables[key]
- AttributeError: 'module' object has no attribute 'tables'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement