Advertisement
Guest User

Untitled

a guest
May 20th, 2017
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 5.34 KB | None | 0 0
  1. """The application's model objects"""
  2. import sqlalchemy as sa
  3. from sqlalchemy.ext.declarative import declarative_base
  4. from sqlalchemy.orm import synonym
  5.  
  6. from mangas.model import meta
  7.  
  8. from hashlib import sha224
  9.  
  10.  
  11. def init_model(engine):
  12.     """Call me before using any of the tables or classes in the model"""
  13.     ## Reflected tables must be defined and mapped here
  14.     #global reflected_table
  15.     #reflected_table = sa.Table("Reflected", meta.metadata, autoload=True,
  16.     #                           autoload_with=engine)
  17.     #orm.mapper(Reflected, reflected_table)
  18.     #
  19.     meta.Session.configure(bind=engine)
  20.     meta.engine = engine
  21.  
  22.  
  23. _Base = declarative_base(metadata=meta)
  24.  
  25. class Users(_Base):
  26.     __tablename__ = 'users'
  27.    
  28.     id = sa.Column("id", sa.types.Integer, primary_key=True)
  29.     username = sa.Column("username", sa.types.Unicode(20), nullable=False)
  30.     email = sa.Column("email", sa.types.Unicode(100), nullable=False)
  31.     _password = sa.Column("password", sa.types.Unicode(64), nullable=False)
  32.        
  33.     def _set_password(self, password):
  34.         hashed_password = sha224(password.encode('UTF-8')).hexdigest()
  35.        
  36.         if not isinstance(hashed_password, unicode):
  37.             hashed_password = hashed_password.decode('UTF-8')
  38.        
  39.         self._password = hashed_password
  40.    
  41.     def _get_password(self):
  42.         return _password
  43.    
  44.     password = synonym('_password', descriptor=property(_get_password, _set_password))
  45.    
  46.     def validate_password(self, password):
  47.         hashed_password = sha224(password.encode('UTF-8')).hexdigest()
  48.         return self.password == hashed_password
  49.  
  50. Traceback (most recent call last):
  51.   File "/usr/local/bin/paster", line 8, in <module>
  52.     load_entry_point('PasteScript==1.7.3', 'console_scripts', 'paster')()
  53.   File "/Library/Python/2.6/site-packages/PasteScript-1.7.3-py2.6.egg/paste/script/command.py", line 84, in run
  54.     invoke(command, command_name, options, args[1:])
  55.   File "/Library/Python/2.6/site-packages/PasteScript-1.7.3-py2.6.egg/paste/script/command.py", line 123, in invoke
  56.     exit_code = runner.run(args)
  57.   File "/Library/Python/2.6/site-packages/PasteScript-1.7.3-py2.6.egg/paste/script/appinstall.py", line 68, in run
  58.     return super(AbstractInstallCommand, self).run(new_args)
  59.   File "/Library/Python/2.6/site-packages/PasteScript-1.7.3-py2.6.egg/paste/script/command.py", line 218, in run
  60.     result = self.command()
  61.   File "/Library/Python/2.6/site-packages/PasteScript-1.7.3-py2.6.egg/paste/script/appinstall.py", line 447, in command
  62.     conf = appconfig(config_spec, relative_to=os.getcwd())
  63.   File "/Library/Python/2.6/site-packages/PasteDeploy-1.3.3-py2.6.egg/paste/deploy/loadwsgi.py", line 215, in appconfig
  64.     global_conf=global_conf)
  65.   File "/Library/Python/2.6/site-packages/PasteDeploy-1.3.3-py2.6.egg/paste/deploy/loadwsgi.py", line 248, in loadcontext
  66.     global_conf=global_conf)
  67.   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
  68.    return loader.get_context(object_type, name, global_conf)
  69.  File "/Library/Python/2.6/site-packages/PasteDeploy-1.3.3-py2.6.egg/paste/deploy/loadwsgi.py", line 409, in get_context
  70.    section)
  71.  File "/Library/Python/2.6/site-packages/PasteDeploy-1.3.3-py2.6.egg/paste/deploy/loadwsgi.py", line 431, in _context_from_use
  72.    object_type, name=use, global_conf=global_conf)
  73.  File "/Library/Python/2.6/site-packages/PasteDeploy-1.3.3-py2.6.egg/paste/deploy/loadwsgi.py", line 361, in get_context
  74.    global_conf=global_conf)
  75.  File "/Library/Python/2.6/site-packages/PasteDeploy-1.3.3-py2.6.egg/paste/deploy/loadwsgi.py", line 248, in loadcontext
  76.    global_conf=global_conf)
  77.  File "/Library/Python/2.6/site-packages/PasteDeploy-1.3.3-py2.6.egg/paste/deploy/loadwsgi.py", line 285, in _loadegg
  78.    return loader.get_context(object_type, name, global_conf)
  79.  File "/Library/Python/2.6/site-packages/PasteDeploy-1.3.3-py2.6.egg/paste/deploy/loadwsgi.py", line 561, in get_context
  80.    object_type, name=name)
  81.  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
  82.    possible.append((entry.load(), protocol, entry.name))
  83.  File "/Library/Python/2.6/site-packages/setuptools-0.6c11-py2.6.egg/pkg_resources.py", line 1954, in load
  84.    
  85.  File "/Users/francescom/Documents/Dev/mangas/mangas/config/middleware.py", line 12, in <module>
  86.    from mangas.config.environment import load_environment
  87.  File "/Users/francescom/Documents/Dev/mangas/mangas/config/environment.py", line 12, in <module>
  88.    from mangas.model import init_model
  89.  File "/Users/francescom/Documents/Dev/mangas/mangas/model/__init__.py", line 23, in <module>
  90.    class Users(_Base):
  91.  File "/Library/Python/2.6/site-packages/SQLAlchemy-0.5.8-py2.6.egg/sqlalchemy/ext/declarative.py", line 561, in __init__
  92.    _as_declarative(cls, classname, dict_)
  93.  File "/Library/Python/2.6/site-packages/SQLAlchemy-0.5.8-py2.6.egg/sqlalchemy/ext/declarative.py", line 494, in _as_declarative
  94.    *(tuple(cols) + tuple(args)), **table_kw)
  95.  File "/Library/Python/2.6/site-packages/SQLAlchemy-0.5.8-py2.6.egg/sqlalchemy/schema.py", line 94, in __call__
  96.    table = metadata.tables[key]
  97. AttributeError: 'module' object has no attribute 'tables'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement