Permalink
Browse files

now names of system events are string

  • Loading branch information...
1 parent 5d7b0ae commit ddc99821f1b229735a9e04fdc84ee6d0f81b3d57 @stanfeldman committed Aug 28, 2012
View
@@ -1,11 +0,0 @@
-BeforeControllerAction = 2
-"""
-Event before controller action will be executed.
-You can change Request object before it will pass to controller action.
-"""
-
-AfterControllerAction = 3
-"""
-Event after controller action was executed.
-You can change Response object before rendering.
-"""
@@ -6,7 +6,6 @@
from kiss.core.exceptions import *
from kiss.core.events import Eventer
import traceback
-import events
import inspect
@@ -50,14 +49,14 @@ def route(self, request):
if mtch:
request.params = mtch.groupdict()
try:
- self.eventer.publish(events.BeforeControllerAction, request)
+ self.eventer.publish("BeforeControllerAction", request)
#check if controller has method for all requests
if hasattr(controller, "process") and inspect.ismethod(getattr(controller, "process")):
action = getattr(controller, "process")
else:
action = getattr(controller, request.method.lower())
response = action(request)
- self.eventer.publish(events.AfterControllerAction, request, response)
+ self.eventer.publish("AfterControllerAction", request, response)
if not response:
break
return response
View
@@ -9,11 +9,11 @@
from kiss.views.core import Request, Response
from beaker.middleware import SessionMiddleware
from werkzeug.wsgi import SharedDataMiddleware
-from kiss.core.events import *
from kiss.views.static import StaticBuilder
from kiss.views.core import Templater
from kiss.models import metadata
import logging
+from kiss.core.events import Eventer
class Application(Singleton):
@@ -26,17 +26,17 @@ def __init__(self, options):
self.init_eventer()
self.init_router()
self.init_templater()
- self.eventer.publish(BeforeDatabaseEngineConfiguration, self)
+ self.eventer.publish("BeforeDatabaseEngineConfiguration", self)
self.init_db()
- self.eventer.publish(AfterDatabaseEngineConfiguration, self)
+ self.eventer.publish("AfterDatabaseEngineConfiguration", self)
self.init_session()
- self.eventer.publish(BeforeInitStatic, self)
+ self.eventer.publish("BeforeInitStatic", self)
self.init_static()
- self.eventer.publish(AfterInitStatic, self)
- self.eventer.publish(BeforeInitServer, self)
+ self.eventer.publish("AfterInitStatic", self)
+ self.eventer.publish("BeforeInitServer", self)
self.init_server()
- self.eventer.publish(AfterInitServer, self)
- self.eventer.publish(BeforeApplicationStarted, self)
+ self.eventer.publish("AfterInitServer", self)
+ self.eventer.publish("BeforeApplicationStarted", self)
def init_options(self, options):
logging.basicConfig(level=logging.CRITICAL)
@@ -123,15 +123,15 @@ def wsgi_app(self, options, start_response):
def start(self):
gevent.signal(signal.SIGTERM, self.stop)
gevent.signal(signal.SIGINT, self.stop)
- self.eventer.publish(ApplicationStarted, self)
+ self.eventer.publish("ApplicationStarted", self)
self.server.serve_forever()
def start_no_wait(self):
- self.eventer.publish(ApplicationStarted, self)
+ self.eventer.publish("ApplicationStarted", self)
self.server.start()
def stop(self):
- self.eventer.publish(ApplicationStopped, self)
+ self.eventer.publish("ApplicationStopped", self)
self.server.stop()
if self.db_engine:
self.db_engine.close()
View
@@ -1,14 +1,11 @@
from pev import Eventer
-
-ApplicationStarted = 0
"""
+ApplicationStarted = 0
+
Event when application is started
-"""
ApplicationStopped = 1
-"""
Event when application is stopped
-"""
BeforeDatabaseEngineConfiguration = 2
AfterDatabaseEngineConfiguration = 3
@@ -17,3 +14,12 @@
BeforeApplicationStarted = 6
BeforeInitServer = 7
AfterInitServer = 8
+
+BeforeControllerAction = 2
+Event before controller action will be executed.
+You can change Request object before it will pass to controller action.
+
+AfterControllerAction = 3
+Event after controller action was executed.
+You can change Response object before rendering.
+"""
View
@@ -8,7 +8,6 @@
from kiss.core.application import Application
from controllers.controller1 import Controller1
from controllers.controller2 import Controller2
-from kiss.core.events import ApplicationStarted
from kiss.controllers.events import BeforeControllerAction
from kiss.core.exceptions import InternalServerError
from kiss.controllers.page import PageController
@@ -65,7 +64,7 @@
"translations": ["views.locales"]
},
"events": {
- ApplicationStarted: Controller2.application_after_load,
+ "ApplicationStarted": Controller2.application_after_load,
InternalServerError.code: Controller2.internal_server_error
},
"models": {
File renamed without changes.
@@ -6,7 +6,6 @@
</head>
<body>
<div>{{ foo }}</div>
- <div>trans:{% trans %}Mary{% endtrans %}, {{_("lamb")}}</div>
<ul>
{% for user in users %}
<li><a href="{{ user.url }}">{{ user.username }}</a></li>
View
@@ -6,7 +6,7 @@
setup(
name = "kiss.py",
- version = "0.4.8",
+ version = "0.4.9",
author = "Stanislav Feldman",
description = ("MVC web framework in Python with Gevent, Jinja2, Werkzeug"),
url = "http://stanislavfeldman.github.com/kiss.py/",

0 comments on commit ddc9982

Please sign in to comment.