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