Show More
@@ -1,103 +1,94 b'' | |||
|
1 | 1 | ################################################################################ |
|
2 | 2 | ################################################################################ |
|
3 | 3 | # pylons_app - Pylons environment configuration # |
|
4 | 4 | # # |
|
5 | 5 | # The %(here)s variable will be replaced with the parent directory of this file# |
|
6 | 6 | ################################################################################ |
|
7 | 7 | |
|
8 | 8 | [DEFAULT] |
|
9 | 9 | debug = true |
|
10 | 10 | ############################################ |
|
11 | 11 | ## Uncomment and replace with the address ## |
|
12 | 12 | ## which should receive any error reports ## |
|
13 | 13 | ############################################ |
|
14 | 14 | #email_to = marcin.kuzminski@etelko.pl |
|
15 | 15 | #smtp_server = mail.etelko.pl |
|
16 | 16 | #error_email_from = paste_error@localhost |
|
17 | 17 | #smtp_username = |
|
18 | 18 | #smtp_password = |
|
19 | 19 | #error_message = 'mercurial crash !' |
|
20 | 20 | |
|
21 | 21 | [server:main] |
|
22 | 22 | use = egg:Paste#http |
|
23 | 23 | host = 127.0.0.1 |
|
24 | 24 | port = 5000 |
|
25 | 25 | |
|
26 | 26 | [app:main] |
|
27 | 27 | use = egg:pylons_app |
|
28 | 28 | full_stack = true |
|
29 |
static_files = |
|
|
29 | static_files = false | |
|
30 | 30 | lang=en |
|
31 | 31 | cache_dir = %(here)s/data |
|
32 | 32 | |
|
33 | 33 | ################################################################################ |
|
34 | 34 | ## WARNING: *THE LINE BELOW MUST BE UNCOMMENTED ON A PRODUCTION ENVIRONMENT* ## |
|
35 | 35 | ## Debug mode will enable the interactive debugging tool, allowing ANYONE to ## |
|
36 | 36 | ## execute malicious code after an exception is raised. ## |
|
37 | 37 | ################################################################################ |
|
38 | 38 | #set debug = false |
|
39 | 39 | |
|
40 | 40 | |
|
41 | 41 | ################################ |
|
42 | 42 | ### LOGGING CONFIGURATION #### |
|
43 | 43 | ################################ |
|
44 | 44 | [loggers] |
|
45 | 45 | keys = root, routes, pylons_app, sqlalchemy |
|
46 | 46 | |
|
47 | 47 | [handlers] |
|
48 |
keys = console |
|
|
48 | keys = console | |
|
49 | 49 | |
|
50 | 50 | [formatters] |
|
51 |
keys = generic |
|
|
51 | keys = generic | |
|
52 | 52 | |
|
53 | 53 | ############# |
|
54 | 54 | ## LOGGERS ## |
|
55 | 55 | ############# |
|
56 | 56 | [logger_root] |
|
57 | 57 | level = NOTSET |
|
58 | 58 | handlers = console |
|
59 | 59 | |
|
60 | 60 | [logger_routes] |
|
61 | 61 | level = INFO |
|
62 | 62 | handlers = console |
|
63 | 63 | qualname = routes.middleware |
|
64 | 64 | # "level = DEBUG" logs the route matched and routing variables. |
|
65 | 65 | |
|
66 | 66 | [logger_pylons_app] |
|
67 | 67 | level = DEBUG |
|
68 | 68 | handlers = console |
|
69 | 69 | qualname = pylons_app |
|
70 | 70 | |
|
71 | 71 | |
|
72 | 72 | [logger_sqlalchemy] |
|
73 | 73 | level = DEBUG |
|
74 | 74 | handlers = console |
|
75 | 75 | qualname = sqlalchemy.engine |
|
76 | 76 | |
|
77 | 77 | ############## |
|
78 | 78 | ## HANDLERS ## |
|
79 | 79 | ############## |
|
80 | 80 | |
|
81 | 81 | [handler_console] |
|
82 | 82 | class = StreamHandler |
|
83 | 83 | args = (sys.stderr,) |
|
84 | 84 | level = NOTSET |
|
85 | 85 | formatter = generic |
|
86 | 86 | |
|
87 | [handler_chainsaw] | |
|
88 | class = xmllayout.RawSocketHandler | |
|
89 | args = ('localhost', 4448) | |
|
90 | level = NOTSET | |
|
91 | formatter = xmllayout | |
|
92 | ||
|
93 | 87 | ################ |
|
94 | 88 | ## FORMATTERS ## |
|
95 | 89 | ################ |
|
96 | 90 | |
|
97 | 91 | [formatter_generic] |
|
98 | 92 | format = %(asctime)s,%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s |
|
99 | 93 | datefmt = %H:%M:%S |
|
100 | 94 | |
|
101 | [formatter_xmllayout] | |
|
102 | class = xmllayout.XMLLayout | |
|
103 |
@@ -1,93 +1,93 b'' | |||
|
1 | 1 | ################################################################################ |
|
2 | 2 | ################################################################################ |
|
3 | 3 | # pylons_app - Pylons environment configuration # |
|
4 | 4 | # # |
|
5 | 5 | # The %(here)s variable will be replaced with the parent directory of this file# |
|
6 | 6 | ################################################################################ |
|
7 | 7 | |
|
8 | 8 | [DEFAULT] |
|
9 | 9 | debug = true |
|
10 | 10 | ############################################ |
|
11 | 11 | ## Uncomment and replace with the address ## |
|
12 | 12 | ## which should receive any error reports ## |
|
13 | 13 | ############################################ |
|
14 | 14 | #email_to = marcin.kuzminski@etelko.pl |
|
15 | 15 | #smtp_server = mail.etelko.pl |
|
16 | 16 | #error_email_from = paste_error@localhost |
|
17 | 17 | #smtp_username = |
|
18 | 18 | #smtp_password = |
|
19 | 19 | #error_message = 'mercurial crash !' |
|
20 | 20 | |
|
21 | 21 | [server:main] |
|
22 | 22 | use = egg:Paste#http |
|
23 | 23 | host = 127.0.0.1 |
|
24 | 24 | port = 8001 |
|
25 | 25 | |
|
26 | 26 | [app:main] |
|
27 | 27 | use = egg:pylons_app |
|
28 | 28 | full_stack = true |
|
29 |
static_files = |
|
|
29 | static_files = false | |
|
30 | 30 | lang=en |
|
31 | 31 | cache_dir = %(here)s/data |
|
32 | 32 | |
|
33 | 33 | ################################################################################ |
|
34 | 34 | ## WARNING: *THE LINE BELOW MUST BE UNCOMMENTED ON A PRODUCTION ENVIRONMENT* ## |
|
35 | 35 | ## Debug mode will enable the interactive debugging tool, allowing ANYONE to ## |
|
36 | 36 | ## execute malicious code after an exception is raised. ## |
|
37 | 37 | ################################################################################ |
|
38 | 38 | #set debug = false |
|
39 | 39 | |
|
40 | 40 | ################################ |
|
41 | 41 | ### LOGGING CONFIGURATION #### |
|
42 | 42 | ################################ |
|
43 | 43 | [loggers] |
|
44 | 44 | keys = root, routes, pylons_app, sqlalchemy |
|
45 | 45 | |
|
46 | 46 | [handlers] |
|
47 | 47 | keys = console |
|
48 | 48 | |
|
49 | 49 | [formatters] |
|
50 | 50 | keys = generic |
|
51 | 51 | |
|
52 | 52 | ############# |
|
53 | 53 | ## LOGGERS ## |
|
54 | 54 | ############# |
|
55 | 55 | [logger_root] |
|
56 | 56 | level = INFO |
|
57 | 57 | handlers = console |
|
58 | 58 | |
|
59 | 59 | [logger_routes] |
|
60 | 60 | level = INFO |
|
61 | 61 | handlers = console |
|
62 | 62 | qualname = routes.middleware |
|
63 | 63 | # "level = DEBUG" logs the route matched and routing variables. |
|
64 | 64 | |
|
65 | 65 | [logger_pylons_app] |
|
66 | 66 | level = DEBUG |
|
67 | 67 | handlers = console |
|
68 | 68 | qualname = pylons_app |
|
69 | 69 | |
|
70 | 70 | |
|
71 | 71 | [logger_sqlalchemy] |
|
72 | 72 | level = DEBUG |
|
73 | 73 | handlers = console |
|
74 | 74 | qualname = sqlalchemy.engine |
|
75 | 75 | |
|
76 | 76 | ############## |
|
77 | 77 | ## HANDLERS ## |
|
78 | 78 | ############## |
|
79 | 79 | |
|
80 | 80 | [handler_console] |
|
81 | 81 | class = StreamHandler |
|
82 | 82 | args = (sys.stderr,) |
|
83 | 83 | level = NOTSET |
|
84 | 84 | formatter = generic |
|
85 | 85 | |
|
86 | 86 | ################ |
|
87 | 87 | ## FORMATTERS ## |
|
88 | 88 | ################ |
|
89 | 89 | |
|
90 | 90 | [formatter_generic] |
|
91 | 91 | format = %(asctime)s,%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s |
|
92 | 92 | datefmt = %H:%M:%S |
|
93 | 93 |
@@ -1,65 +1,65 b'' | |||
|
1 | 1 | """Pylons middleware initialization""" |
|
2 | 2 | from beaker.middleware import CacheMiddleware, SessionMiddleware |
|
3 | 3 | from paste.cascade import Cascade |
|
4 | 4 | from paste.registry import RegistryManager |
|
5 | 5 | from paste.urlparser import StaticURLParser |
|
6 | 6 | from paste.deploy.converters import asbool |
|
7 | 7 | from pylons import config |
|
8 | 8 | from pylons.middleware import ErrorHandler, StatusCodeRedirect |
|
9 | 9 | from pylons.wsgiapp import PylonsApp |
|
10 | 10 | from routes.middleware import RoutesMiddleware |
|
11 | ||
|
11 | 12 | from pylons_app.config.environment import load_environment |
|
12 | 13 | |
|
13 | 14 | |
|
14 | ||
|
15 | 15 | def make_app(global_conf, full_stack = True, **app_conf): |
|
16 | 16 | """Create a Pylons WSGI application and return it |
|
17 | 17 | |
|
18 | 18 | ``global_conf`` |
|
19 | 19 | The inherited configuration for this application. Normally from |
|
20 | 20 | the [DEFAULT] section of the Paste ini file. |
|
21 | 21 | |
|
22 | 22 | ``full_stack`` |
|
23 | 23 | Whether or not this application provides a full WSGI stack (by |
|
24 | 24 | default, meaning it handles its own exceptions and errors). |
|
25 | 25 | Disable full_stack when this application is "managed" by |
|
26 | 26 | another WSGI middleware. |
|
27 | 27 | |
|
28 | 28 | ``app_conf`` |
|
29 | 29 | The application's local configuration. Normally specified in |
|
30 | 30 | the [app:<name>] section of the Paste ini file (where <name> |
|
31 | 31 | defaults to main). |
|
32 | 32 | |
|
33 | 33 | """ |
|
34 | 34 | # Configure the Pylons environment |
|
35 | 35 | load_environment(global_conf, app_conf) |
|
36 | 36 | |
|
37 | 37 | # The Pylons WSGI app |
|
38 | 38 | app = PylonsApp() |
|
39 | 39 | |
|
40 | 40 | # CUSTOM MIDDLEWARE HERE (filtered by error handling middlewares) |
|
41 | 41 | |
|
42 | 42 | # Routing/Session/Cache Middleware |
|
43 | 43 | app = RoutesMiddleware(app, config['routes.map']) |
|
44 | 44 | |
|
45 | 45 | if asbool(full_stack): |
|
46 | 46 | # Handle Python exceptions |
|
47 | 47 | app = ErrorHandler(app, global_conf, **config['pylons.errorware']) |
|
48 | 48 | |
|
49 | 49 | # Display error documents for 401, 403, 404 status codes (and |
|
50 | 50 | # 500 when debug is disabled) |
|
51 | 51 | if asbool(config['debug']): |
|
52 | 52 | #don't handle 404, since mercurial does it for us. |
|
53 | 53 | app = StatusCodeRedirect(app, [400, 401, 403, 500]) |
|
54 | 54 | else: |
|
55 | 55 | app = StatusCodeRedirect(app, [400, 401, 403, 500]) |
|
56 | 56 | |
|
57 | 57 | # Establish the Registry for this application |
|
58 | 58 | app = RegistryManager(app) |
|
59 | 59 | |
|
60 | 60 | # Static files (If running in production, and Apache or another web |
|
61 | 61 | # server is handling this static content, remove the following 3 lines) |
|
62 | 62 | static_app = StaticURLParser(config['pylons.paths']['static_files']) |
|
63 | 63 | app = Cascade([static_app, app]) |
|
64 | 64 | return app |
|
65 | 65 |
@@ -1,20 +1,19 b'' | |||
|
1 | 1 | """The base Controller API |
|
2 | 2 | |
|
3 | 3 | Provides the BaseController class for subclassing. |
|
4 | 4 | """ |
|
5 | 5 | from pylons.controllers import WSGIController |
|
6 | 6 | from pylons.templating import render_mako as render |
|
7 | 7 | from pylons_app.model import meta |
|
8 | 8 | |
|
9 | 9 | class BaseController(WSGIController): |
|
10 | 10 | |
|
11 | 11 | def __call__(self, environ, start_response): |
|
12 | 12 | """Invoke the Controller""" |
|
13 | 13 | # WSGIController.__call__ dispatches to the Controller method |
|
14 | 14 | # the request is routed to. This routing information is |
|
15 | 15 | # available in environ['pylons.routes_dict'] |
|
16 | 16 | try: |
|
17 | 17 | return WSGIController.__call__(self, environ, start_response) |
|
18 | 18 | finally: |
|
19 | 19 | pass |
|
20 | #meta.Session.remove() |
General Comments 0
You need to be logged in to leave comments.
Login now