Permalink
Browse files

fixed db configure problem

  • Loading branch information...
1 parent 320dfee commit 7d16d978204d8f9308bdfb092bf169045249f965 @stanfeldman committed Aug 3, 2012
Showing with 9 additions and 4 deletions.
  1. +5 −3 kiss/core/application.py
  2. +3 −0 kiss/core/events.py
  3. +1 −1 setup.py
View
@@ -3,13 +3,13 @@
from gevent import monkey; monkey.patch_all()
from gevent.wsgi import WSGIServer
from putils.patterns import Singleton
-from putils.dynamics import Importer
+from putils.dynamics import Importer, Introspector
from putils.types import Dict
from kiss.controllers.router import Router
from kiss.views.core import Request, Response
from beaker.middleware import SessionMiddleware
from werkzeug.wsgi import SharedDataMiddleware
-from kiss.core.events import Eventer, ApplicationStarted, ApplicationStopped
+from kiss.core.events import Eventer, ApplicationStarted, ApplicationStopped, BeforeDatabaseEngineConfiguration, AfterDatabaseEngineConfiguration
from kiss.views.static import StaticBuilder
from kiss.models import Model
import logging
@@ -24,7 +24,9 @@ def __init__(self, options):
self.options = Application.init_options(options)
self.options, self.eventer = Application.init_eventer(options)
self.options, self.router = Application.init_router(options)
+ self.eventer.publish(BeforeDatabaseEngineConfiguration, self)
self.options, self.db_engine = Application.init_db(self.options)
+ self.eventer.publish(AfterDatabaseEngineConfiguration, self)
self.options, self.static_builder = Application.init_static(self.options)
self.options, self.wsgi_app = Application.init_session(self.options, self.wsgi_app)
self.options, self.wsgi_app = Application.init_static_server(self.options, self.wsgi_app)
@@ -83,7 +85,7 @@ def init_db(options):
db_engine = db_engine_class(db_name, **options["models"])
db_engine.connect()
db_engine.set_autocommit(True)
- for m in Model.__subclasses__():
+ for m in Introspector.all_subclasses(Model):
m._meta.database = db_engine
return (options, db_engine)
View
@@ -9,3 +9,6 @@
"""
Event when application is stopped
"""
+
+BeforeDatabaseEngineConfiguration = 2
+AfterDatabaseEngineConfiguration = 3
View
@@ -6,7 +6,7 @@
setup(
name = "kiss.py",
- version = "0.3.6",
+ version = "0.3.7",
author = "Stanislav Feldman",
description = ("MVC web framework in Python with Gevent, Jinja2, Werkzeug"),
url = "http://stanislavfeldman.github.com/kiss.py/",

0 comments on commit 7d16d97

Please sign in to comment.