##// END OF EJS Templates
Added few options to configs,...
Marcin Kuzminski -
r86:e47d1db5 default
parent child Browse files
Show More
@@ -1,119 +1,127 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 ##nr of threads to spawn
22 threadpool_workers = 5
23 threadpool_workers = 5
24
25 ##max request before
26 threadpool_max_requests = 2
27
28 ##option to use threads of process
29 use_threadpool = true
30
23 use = egg:Paste#http
31 use = egg:Paste#http
24 host = 127.0.0.1
32 host = 127.0.0.1
25 port = 5000
33 port = 5000
26
34
27 [app:main]
35 [app:main]
28 use = egg:pylons_app
36 use = egg:pylons_app
29 full_stack = true
37 full_stack = true
30 static_files = true
38 static_files = true
31 lang=en
39 lang=en
32 cache_dir = %(here)s/data
40 cache_dir = %(here)s/data
33 repos_name = Python-works
41 repos_name = Python-works
34
42
35 ####################################
43 ####################################
36 ### BEAKER CACHE ####
44 ### BEAKER CACHE ####
37 ####################################
45 ####################################
38 beaker.cache.data_dir=/tmp/cache/data
46 beaker.cache.data_dir=/tmp/cache/data
39 beaker.cache.lock_dir=/tmp/cache/lock
47 beaker.cache.lock_dir=/tmp/cache/lock
40 beaker.cache.regions=short_term
48 beaker.cache.regions=short_term
41 beaker.cache.short_term.type=memory
49 beaker.cache.short_term.type=memory
42 beaker.cache.short_term.expire=3600
50 beaker.cache.short_term.expire=3600
43
51
44 ################################################################################
52 ################################################################################
45 ## WARNING: *THE LINE BELOW MUST BE UNCOMMENTED ON A PRODUCTION ENVIRONMENT* ##
53 ## WARNING: *THE LINE BELOW MUST BE UNCOMMENTED ON A PRODUCTION ENVIRONMENT* ##
46 ## Debug mode will enable the interactive debugging tool, allowing ANYONE to ##
54 ## Debug mode will enable the interactive debugging tool, allowing ANYONE to ##
47 ## execute malicious code after an exception is raised. ##
55 ## execute malicious code after an exception is raised. ##
48 ################################################################################
56 ################################################################################
49 #set debug = false
57 #set debug = false
50
58
51 ##################################
59 ##################################
52 ### LOGVIEW CONFIG ###
60 ### LOGVIEW CONFIG ###
53 ##################################
61 ##################################
54 logview.sqlalchemy = #faa
62 logview.sqlalchemy = #faa
55 logview.pylons.templating = #bfb
63 logview.pylons.templating = #bfb
56 logview.pylons.util = #eee
64 logview.pylons.util = #eee
57
65
58 #########################################################
66 #########################################################
59 ### DB CONFIGS - EACH DB WILL HAVE IT'S OWN CONFIG ###
67 ### DB CONFIGS - EACH DB WILL HAVE IT'S OWN CONFIG ###
60 #########################################################
68 #########################################################
61 sqlalchemy.db1.url = sqlite:///%(here)s/hg_app.db
69 sqlalchemy.db1.url = sqlite:///%(here)s/hg_app.db
62 #sqlalchemy.db1.echo = True
70 #sqlalchemy.db1.echo = True
63 #sqlalchemy.db1.pool_recycle = 3600
71 #sqlalchemy.db1.pool_recycle = 3600
64 sqlalchemy.convert_unicode = true
72 sqlalchemy.convert_unicode = true
65
73
66 ################################
74 ################################
67 ### LOGGING CONFIGURATION ####
75 ### LOGGING CONFIGURATION ####
68 ################################
76 ################################
69 [loggers]
77 [loggers]
70 keys = root, routes, pylons_app, sqlalchemy
78 keys = root, routes, pylons_app, sqlalchemy
71
79
72 [handlers]
80 [handlers]
73 keys = console
81 keys = console
74
82
75 [formatters]
83 [formatters]
76 keys = generic
84 keys = generic
77
85
78 #############
86 #############
79 ## LOGGERS ##
87 ## LOGGERS ##
80 #############
88 #############
81 [logger_root]
89 [logger_root]
82 level = NOTSET
90 level = NOTSET
83 handlers = console
91 handlers = console
84
92
85 [logger_routes]
93 [logger_routes]
86 level = DEBUG
94 level = DEBUG
87 handlers = console
95 handlers = console
88 qualname = routes.middleware
96 qualname = routes.middleware
89 # "level = DEBUG" logs the route matched and routing variables.
97 # "level = DEBUG" logs the route matched and routing variables.
90
98
91 [logger_pylons_app]
99 [logger_pylons_app]
92 level = DEBUG
100 level = DEBUG
93 handlers = console
101 handlers = console
94 qualname = pylons_app
102 qualname = pylons_app
95
103
96
104
97 [logger_sqlalchemy]
105 [logger_sqlalchemy]
98 level = DEBUG
106 level = DEBUG
99 handlers = console
107 handlers = console
100 qualname = sqlalchemy.engine
108 qualname = sqlalchemy.engine
101
109
102 ##############
110 ##############
103 ## HANDLERS ##
111 ## HANDLERS ##
104 ##############
112 ##############
105
113
106 [handler_console]
114 [handler_console]
107 class = StreamHandler
115 class = StreamHandler
108 args = (sys.stderr,)
116 args = (sys.stderr,)
109 level = NOTSET
117 level = NOTSET
110 formatter = generic
118 formatter = generic
111
119
112 ################
120 ################
113 ## FORMATTERS ##
121 ## FORMATTERS ##
114 ################
122 ################
115
123
116 [formatter_generic]
124 [formatter_generic]
117 format = %(asctime)s,%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s
125 format = %(asctime)s,%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s
118 datefmt = %Y-%m-%d %H:%M:%S
126 datefmt = %Y-%m-%d %H:%M:%S
119
127
@@ -1,119 +1,127 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 threadpool_workers = 10
22 ##nr of threads to spawn
23 threadpool_workers = 5
24
25 ##max request before
26 threadpool_max_requests = 2
27
28 ##option to use threads of process
29 use_threadpool = true
30
23 use = egg:Paste#http
31 use = egg:Paste#http
24 host = 127.0.0.1
32 host = 127.0.0.1
25 port = 8001
33 port = 8001
26
34
27 [app:main]
35 [app:main]
28 use = egg:pylons_app
36 use = egg:pylons_app
29 full_stack = true
37 full_stack = true
30 static_files = true
38 static_files = true
31 lang=en
39 lang=en
32 cache_dir = %(here)s/data
40 cache_dir = %(here)s/data
33 repos_name = Python-works
41 repos_name = Python-works
34
42
35 ####################################
43 ####################################
36 ### BEAKER CACHE ####
44 ### BEAKER CACHE ####
37 ####################################
45 ####################################
38 beaker.cache.data_dir=/tmp/cache/data
46 beaker.cache.data_dir=/tmp/cache/data
39 beaker.cache.lock_dir=/tmp/cache/lock
47 beaker.cache.lock_dir=/tmp/cache/lock
40 beaker.cache.regions=short_term
48 beaker.cache.regions=short_term
41 beaker.cache.short_term.type=memory
49 beaker.cache.short_term.type=memory
42 beaker.cache.short_term.expire=3600
50 beaker.cache.short_term.expire=3600
43
51
44 ################################################################################
52 ################################################################################
45 ## WARNING: *THE LINE BELOW MUST BE UNCOMMENTED ON A PRODUCTION ENVIRONMENT* ##
53 ## WARNING: *THE LINE BELOW MUST BE UNCOMMENTED ON A PRODUCTION ENVIRONMENT* ##
46 ## Debug mode will enable the interactive debugging tool, allowing ANYONE to ##
54 ## Debug mode will enable the interactive debugging tool, allowing ANYONE to ##
47 ## execute malicious code after an exception is raised. ##
55 ## execute malicious code after an exception is raised. ##
48 ################################################################################
56 ################################################################################
49 set debug = false
57 set debug = false
50
58
51 ##################################
59 ##################################
52 ### LOGVIEW CONFIG ###
60 ### LOGVIEW CONFIG ###
53 ##################################
61 ##################################
54 logview.sqlalchemy = #faa
62 logview.sqlalchemy = #faa
55 logview.pylons.templating = #bfb
63 logview.pylons.templating = #bfb
56 logview.pylons.util = #eee
64 logview.pylons.util = #eee
57
65
58 #########################################################
66 #########################################################
59 ### DB CONFIGS - EACH DB WILL HAVE IT'S OWN CONFIG ###
67 ### DB CONFIGS - EACH DB WILL HAVE IT'S OWN CONFIG ###
60 #########################################################
68 #########################################################
61 sqlalchemy.db1.url = sqlite:///%(here)s/hg_app.db
69 sqlalchemy.db1.url = sqlite:///%(here)s/hg_app.db
62 #sqlalchemy.db1.echo = True
70 #sqlalchemy.db1.echo = True
63 #sqlalchemy.db1.pool_recycle = 3600
71 #sqlalchemy.db1.pool_recycle = 3600
64 sqlalchemy.convert_unicode = true
72 sqlalchemy.convert_unicode = true
65
73
66 ################################
74 ################################
67 ### LOGGING CONFIGURATION ####
75 ### LOGGING CONFIGURATION ####
68 ################################
76 ################################
69 [loggers]
77 [loggers]
70 keys = root, routes, pylons_app, sqlalchemy
78 keys = root, routes, pylons_app, sqlalchemy
71
79
72 [handlers]
80 [handlers]
73 keys = console
81 keys = console
74
82
75 [formatters]
83 [formatters]
76 keys = generic
84 keys = generic
77
85
78 #############
86 #############
79 ## LOGGERS ##
87 ## LOGGERS ##
80 #############
88 #############
81 [logger_root]
89 [logger_root]
82 level = INFO
90 level = INFO
83 handlers = console
91 handlers = console
84
92
85 [logger_routes]
93 [logger_routes]
86 level = INFO
94 level = INFO
87 handlers = console
95 handlers = console
88 qualname = routes.middleware
96 qualname = routes.middleware
89 # "level = DEBUG" logs the route matched and routing variables.
97 # "level = DEBUG" logs the route matched and routing variables.
90
98
91 [logger_pylons_app]
99 [logger_pylons_app]
92 level = DEBUG
100 level = DEBUG
93 handlers = console
101 handlers = console
94 qualname = pylons_app
102 qualname = pylons_app
95
103
96
104
97 [logger_sqlalchemy]
105 [logger_sqlalchemy]
98 level = DEBUG
106 level = DEBUG
99 handlers = console
107 handlers = console
100 qualname = sqlalchemy.engine
108 qualname = sqlalchemy.engine
101
109
102 ##############
110 ##############
103 ## HANDLERS ##
111 ## HANDLERS ##
104 ##############
112 ##############
105
113
106 [handler_console]
114 [handler_console]
107 class = StreamHandler
115 class = StreamHandler
108 args = (sys.stderr,)
116 args = (sys.stderr,)
109 level = NOTSET
117 level = NOTSET
110 formatter = generic
118 formatter = generic
111
119
112 ################
120 ################
113 ## FORMATTERS ##
121 ## FORMATTERS ##
114 ################
122 ################
115
123
116 [formatter_generic]
124 [formatter_generic]
117 format = %(asctime)s,%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s
125 format = %(asctime)s,%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s
118 datefmt = %Y-%m-%d %H:%M:%S
126 datefmt = %Y-%m-%d %H:%M:%S
119
127
@@ -1,70 +1,69 b''
1 """Pylons middleware initialization"""
1 """Pylons middleware initialization"""
2 from beaker.middleware import SessionMiddleware
2 from beaker.middleware import 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.middleware import ErrorHandler, StatusCodeRedirect
7 from pylons.middleware import ErrorHandler, StatusCodeRedirect
8 from pylons.wsgiapp import PylonsApp
8 from pylons.wsgiapp import PylonsApp
9 from routes.middleware import RoutesMiddleware
9 from routes.middleware import RoutesMiddleware
10 from paste.auth.basic import AuthBasicHandler
10 from paste.auth.basic import AuthBasicHandler
11 from pylons_app.config.environment import load_environment
11 from pylons_app.config.environment import load_environment
12 from pylons_app.lib.auth import authfunc
12 from pylons_app.lib.auth import authfunc
13
13
14 def make_app(global_conf, full_stack=True, static_files=True, **app_conf):
14 def make_app(global_conf, full_stack=True, static_files=True, **app_conf):
15 """Create a Pylons WSGI application and return it
15 """Create a Pylons WSGI application and return it
16
16
17 ``global_conf``
17 ``global_conf``
18 The inherited configuration for this application. Normally from
18 The inherited configuration for this application. Normally from
19 the [DEFAULT] section of the Paste ini file.
19 the [DEFAULT] section of the Paste ini file.
20
20
21 ``full_stack``
21 ``full_stack``
22 Whether or not this application provides a full WSGI stack (by
22 Whether or not this application provides a full WSGI stack (by
23 default, meaning it handles its own exceptions and errors).
23 default, meaning it handles its own exceptions and errors).
24 Disable full_stack when this application is "managed" by
24 Disable full_stack when this application is "managed" by
25 another WSGI middleware.
25 another WSGI middleware.
26
26
27 ``app_conf``
27 ``app_conf``
28 The application's local configuration. Normally specified in
28 The application's local configuration. Normally specified in
29 the [app:<name>] section of the Paste ini file (where <name>
29 the [app:<name>] section of the Paste ini file (where <name>
30 defaults to main).
30 defaults to main).
31
31
32 """
32 """
33 # Configure the Pylons environment
33 # Configure the Pylons environment
34 config = load_environment(global_conf, app_conf)
34 config = load_environment(global_conf, app_conf)
35
35
36
36
37 # The Pylons WSGI app
37 # The Pylons WSGI app
38 app = PylonsApp(config=config)
38 app = PylonsApp(config=config)
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 app = SessionMiddleware(app, config)
44 app = SessionMiddleware(app, config)
45 app = AuthBasicHandler(app, config['repos_name'] + ' mercurial repository', authfunc)
45 app = AuthBasicHandler(app, config['repos_name'] + ' mercurial repository', authfunc)
46
46
47 if asbool(full_stack):
47 if asbool(full_stack):
48 # Handle Python exceptions
48 # Handle Python exceptions
49 app = ErrorHandler(app, global_conf, **config['pylons.errorware'])
49 app = ErrorHandler(app, global_conf, **config['pylons.errorware'])
50
50
51 # Display error documents for 401, 403, 404 status codes (and
51 # Display error documents for 401, 403, 404 status codes (and
52 # 500 when debug is disabled)
52 # 500 when debug is disabled)
53 if asbool(config['debug']):
53 if asbool(config['debug']):
54 #don't handle 404, since mercurial does it for us.
54 app = StatusCodeRedirect(app)
55 app = StatusCodeRedirect(app, [400, 401, 403])
56 else:
55 else:
57 app = StatusCodeRedirect(app, [400, 401, 403, 500])
56 app = StatusCodeRedirect(app, [400, 401, 403, 404, 500])
58
57
59 # Establish the Registry for this application
58 # Establish the Registry for this application
60 app = RegistryManager(app)
59 app = RegistryManager(app)
61
60
62 if asbool(static_files):
61 if asbool(static_files):
63 # Serve static files
62 # Serve static files
64 static_app = StaticURLParser(config['pylons.paths']['static_files'])
63 static_app = StaticURLParser(config['pylons.paths']['static_files'])
65 app = Cascade([static_app, app])
64 app = Cascade([static_app, app])
66
65
67 app.config = config
66 app.config = config
68
67
69 return app
68 return app
70
69
@@ -1,35 +1,34 b''
1 import logging
1 import logging
2
2
3 from pylons import tmpl_context as c, app_globals as g, session, request, config, url
3 from pylons import tmpl_context as c, app_globals as g, session, request, config, url
4 from pylons.controllers.util import abort, redirect
4 from pylons.controllers.util import abort, redirect
5
5
6 from pylons_app.lib.base import BaseController, render
6 from pylons_app.lib.base import BaseController, render
7 from pylons_app.lib.utils import get_repo_slug
7 from pylons_app.lib.utils import get_repo_slug
8 from pylons_app.model.hg_model import HgModel
8 from pylons_app.model.hg_model import HgModel
9 from webhelpers.paginate import Page
9 from webhelpers.paginate import Page
10
10 log = logging.getLogger(__name__)
11 log = logging.getLogger(__name__)
11
12
12 class ShortlogController(BaseController):
13 class ShortlogController(BaseController):
13 def __before__(self):
14 def __before__(self):
14 c.repos_prefix = config['repos_name']
15 c.repos_prefix = config['repos_name']
15 c.staticurl = g.statics
16 c.staticurl = g.statics
16 c.repo_name = get_repo_slug(request)
17 c.repo_name = get_repo_slug(request)
17
18
18
19
19 def index(self):
20 def index(self):
20 hg_model = HgModel()
21 hg_model = HgModel()
21 lim = 20
22 lim = 20
22 p = int(request.params.get('page', 1))
23 p = int(request.params.get('page', 1))
23 repo = hg_model.get_repo(c.repo_name)
24 repo = hg_model.get_repo(c.repo_name)
24 cnt = repo.revisions[-1]
25 cnt = repo.revisions[-1]
25 gen = repo.get_changesets(None)
26 gen = repo.get_changesets(None)
26 repo_changesets = list(gen)
27 repo_changesets = list(gen)
27 repo_changesets2 = list(gen)
28 repo_changesets3 = list(gen)
29 repo_changesets4 = list(gen)
30
28
31 c.repo_changesets = Page(repo_changesets, page=p, item_count=cnt, items_per_page=lim)
29 c.repo_changesets = Page(repo_changesets, page=p, item_count=cnt, items_per_page=lim)
32 c.shortlog_data = render('shortlog_data.html')
30 c.shortlog_data = render('shortlog_data.html')
33 if request.params.get('partial'):
31 if request.params.get('partial'):
34 return c.shortlog_data
32 return c.shortlog_data
35 return render('/shortlog.html')
33 r = render('/shortlog.html')
34 return r
General Comments 0
You need to be logged in to leave comments. Login now