Fichero de configuraciĆ³n y fix en sqla_hook
authordanigm <dani@danigm.net>
Sun, 7 Feb 2010 12:31:37 +0000 (13:31 +0100)
committerdanigm <dani@danigm.net>
Sun, 7 Feb 2010 12:31:37 +0000 (13:31 +0100)
app.py
config.py [new file with mode: 0644]
db.py

diff --git a/app.py b/app.py
index 607835e..7d5143a 100644 (file)
--- a/app.py
+++ b/app.py
@@ -4,6 +4,10 @@
 import web
 import db
 
+import config
+
+web.config.debug = config.DEBUG
+
 urls = (
         '/login', 'view.login.Login',
         '/logout', 'view.login.Logout',
@@ -39,8 +43,7 @@ def load_sqla(handler):
     except:
         web.ctx.orm.rollback()
         raise
-    else:
-        web.ctx.orm.commit()
+    web.ctx.orm.commit()
 
 app.add_processor(load_sqla)
 
diff --git a/config.py b/config.py
new file mode 100644 (file)
index 0000000..9d7874b
--- /dev/null
+++ b/config.py
@@ -0,0 +1,2 @@
+DB = 'sqlite:///database.sqlite'
+DEBUG = True
diff --git a/db.py b/db.py
index c7daa7f..dd5d789 100644 (file)
--- a/db.py
+++ b/db.py
@@ -4,6 +4,8 @@ from sqlalchemy.orm import sessionmaker, scoped_session
 
 from hashlib import sha256 as sha
 
+import config
+
 Base = declarative_base()
 metadata = Base.metadata
 
@@ -36,12 +38,12 @@ class User(Base):
     def __unicode__(self):
         return '<User "%s">' % self.name
 
-def connect(database='sqlite:///database.sqlite'):
+def connect(database=config.DB):
     db = create_engine(database, echo=False)
     session = scoped_session(sessionmaker(bind=db))
     return session
 
-def create(database='sqlite:///database.sqlite'):
+def create(database=config.DB):
     db = create_engine(database, echo=False)
     metadata.create_all(db)