##// END OF EJS Templates
Added pylons manage script...
Marcin Kuzminski -
r12:5f30a6d5 default
parent child Browse files
Show More
@@ -0,0 +1,31 b''
1 #!/bin/sh -e
2 ### BEGIN INIT INFO
3 # Provides: pylons-manage
4 # Required-Start: $all
5 # Required-Stop: $all
6 # Default-Start: 2 3 4 5
7 # Default-Stop: 0 1 6
8 # Short-Description: starts pylons app
9 # Description: starts pylons app
10 ### END INIT INFO
11
12 project_name=hg_app
13 conf_name=development.ini
14 project_path=/home/marcink/python_workspace/$project_name
15 virt_python=/home/marcink/virt_python
16
17 cd $project_path
18 case "$1" in
19 start)
20 $virt_python/bin/paster serve --daemon --pid-file=$project_path/$project_name.pid --log-file=$project_path/$project_name.log $project_path/$conf_name start
21 ;;
22 stop)
23 $virt_python/bin/paster serve --daemon --pid-file=$project_path/$project_name.pid --log-file=$project_path/$project_namete.log $project_path/$conf_name stop
24 ;;
25 restart)
26 $virt_python/bin/paster serve --daemon --pid-file=$project_path/$project_name.pid --log-file=$project_path/$project_name.log $project_path/$conf_name restart
27 ;;
28 *)
29 echo "Usage: $0 {start|stop|restart}"
30 exit 1
31 esac No newline at end of file
@@ -1,18 +1,16 b''
1 ########################################################################
1 ################################################################################
2 ##
2 ################################################################################
3 ## pylons_app - Pylons development 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 [exe]
8 command = serve
9 daemon = false
10 user = nobody
11 group = nobody
12
7
13 [DEFAULT]
8 [DEFAULT]
14 debug = true
9 debug = true
15 ## Uncomment and replace with the address which should receive any error reports
10 ############################################
11 ## Uncomment and replace with the address ##
12 ## which should receive any error reports ##
13 ############################################
16 email_to = marcin.kuzminski@etelko.pl
14 email_to = marcin.kuzminski@etelko.pl
17 smtp_server = localhost
15 smtp_server = localhost
18 error_email_from = paste_error@localhost
16 error_email_from = paste_error@localhost
@@ -20,79 +18,62 b' error_email_from = paste_error@localhost'
20 [server:main]
18 [server:main]
21 use = egg:Paste#http
19 use = egg:Paste#http
22 host = 127.0.0.1
20 host = 127.0.0.1
23 port = 8001
21 port = 5000
24
22
25 [app:main]
23 [app:main]
26 use = egg:pylons_app
24 use = egg:pylons_app
27 full_stack = true
25 full_stack = true
28 static_files = false
26 static_files = true
29 ##default lang
30 lang=en
27 lang=en
31
32 cache_dir = %(here)s/data
28 cache_dir = %(here)s/data
33 beaker.session.key = pylons_app
34 beaker.session.secret = #@^^F&VWUDCT%@$#WR^@&*IWEKF
35 beaker.session.timeout = 3600
36
29
37 ##auto save the session to not to use .save()
30 ################################################################################
38 beaker.session.auto = True
31 ## WARNING: *THE LINE BELOW MUST BE UNCOMMENTED ON A PRODUCTION ENVIRONMENT* ##
39
32 ## Debug mode will enable the interactive debugging tool, allowing ANYONE to ##
40 ##true exire at browser close
33 ## execute malicious code after an exception is raised. ##
41 #beaker.session.cookie_expires = 3600
34 ################################################################################
42
35 #set debug = false
43 ## If you'd like to fine-tune the individual locations of the cache data dirs
44 ## for the Cache data, or the Session saves, un-comment the desired settings
45 ## here:
46 #beaker.cache.data_dir = %(here)s/data/cache
47 #beaker.session.data_dir = %(here)s/data/sessions
48
36
49
37
50 ##Type of storage used for the session, current types are
38 ################################
51 ##“dbm”, “file”, “memcached”, “database”, and “memory”.
39 ### LOGGING CONFIGURATION ####
52 ##The storage uses the Container API that is also used by the cache system.
40 ################################
53 beaker.session.type = memory
54
55 ##if db or memcached is used
56 ##you have to use
57 #beaker.session.url =
58 #beaker.session.table_name =
59
60 ## WARNING: *THE LINE BELOW MUST BE UNCOMMENTED ON A PRODUCTION ENVIRONMENT*
61 ## Debug mode will enable the interactive debugging tool, allowing ANYONE to
62 ## execute malicious code after an exception is raised.
63 #set debug = false
64
65 ##dozer logging
66 logview.pylons.templating = #bfb
67 logview.sample_app.lib = #aaa
68
69 # Logging configuration
70 [loggers]
41 [loggers]
71 keys = root, routes, pylons_app
42 keys = root, routes, pylons_app, sqlalchemy
72
43
73 [handlers]
44 [handlers]
74 keys = console,file_handler
45 keys = console
75
46
76 [formatters]
47 [formatters]
77 keys = generic
48 keys = generic
78
49
50 #############
79 ## LOGGERS ##
51 ## LOGGERS ##
52 #############
80 [logger_root]
53 [logger_root]
81 level = DEBUG
54 level = INFO
82 handlers = console, file_handler
55 handlers = console
83
56
84 [logger_routes]
57 [logger_routes]
85 level = DEBUG
58 level = INFO
86 handlers = console
59 handlers = console
87 qualname = routes.middleware
60 qualname = routes.middleware
88 # "level = DEBUG" logs the route matched and routing variables.
61 # "level = DEBUG" logs the route matched and routing variables.
89
62
90 [logger_pylons_app]
63 [logger_pylons_app]
91 level = DEBUG
64 level = DEBUG
92 handlers = console,file_handler
65 handlers = console
93 qualname = pylons_app
66 qualname = pylons_app
94
67
68
69 [logger_sqlalchemy]
70 level = DEBUG
71 handlers = console
72 qualname = sqlalchemy.engine
73
74 ##############
95 ## HANDLERS ##
75 ## HANDLERS ##
76 ##############
96
77
97 [handler_console]
78 [handler_console]
98 class = StreamHandler
79 class = StreamHandler
@@ -100,13 +81,9 b' args = (sys.stderr,)'
100 level = NOTSET
81 level = NOTSET
101 formatter = generic
82 formatter = generic
102
83
103 [handler_file_handler]
84 ################
104 class = FileHandler
105 args = ('./pylons_app.log','a')
106 level = NOTSET
107 formatter = generic
108
109 ## FORMATTERS ##
85 ## FORMATTERS ##
86 ################
110
87
111 [formatter_generic]
88 [formatter_generic]
112 format = %(asctime)s,%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s
89 format = %(asctime)s,%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s
@@ -11,9 +11,8 b' push_ssl = false'
11 contact = marcin.kuzminski@etelko.pl
11 contact = marcin.kuzminski@etelko.pl
12 allow_archive = gz zip bz2
12 allow_archive = gz zip bz2
13 allow_push = *
13 allow_push = *
14 #style = monoblue
15 style = gitweb
14 style = gitweb
16 Spygments_style = trac
15 pygments_style = trac
17 staticurl = /static
16 staticurl = /static
18 baseurl = /
17 baseurl = /
19
18
@@ -1,18 +1,16 b''
1 ########################################################################
1 ################################################################################
2 ##
2 ################################################################################
3 ## pylons_app - Pylons development 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 [exe]
8 command = serve
9 daemon = false
10 user = nobody
11 group = nobody
12
7
13 [DEFAULT]
8 [DEFAULT]
14 debug = true
9 debug = true
15 ## Uncomment and replace with the address which should receive any error reports
10 ############################################
11 ## Uncomment and replace with the address ##
12 ## which should receive any error reports ##
13 ############################################
16 email_to = marcin.kuzminski@etelko.pl
14 email_to = marcin.kuzminski@etelko.pl
17 smtp_server = localhost
15 smtp_server = localhost
18 error_email_from = paste_error@localhost
16 error_email_from = paste_error@localhost
@@ -24,77 +22,60 b' port = 8001'
24
22
25 [app:main]
23 [app:main]
26 use = egg:pylons_app
24 use = egg:pylons_app
27 full_stack = true
25 full_stack = false
28 static_files = false
26 static_files = true
29 ##default lang
27 #default lang
30 lang=en
28 lang=en
31
29
32 cache_dir = %(here)s/data
30 cache_dir = %(here)s/data
33 beaker.session.key = pylons_app
34 beaker.session.secret = #@^^F&VWUDCT%@$#WR^@&*IWEKF
35 beaker.session.timeout = 3600
36
37 ##auto save the session to not to use .save()
38 beaker.session.auto = True
39
40 ##true exire at browser close
41 #beaker.session.cookie_expires = 3600
42
43 ## If you'd like to fine-tune the individual locations of the cache data dirs
44 ## for the Cache data, or the Session saves, un-comment the desired settings
45 ## here:
46 #beaker.cache.data_dir = %(here)s/data/cache
47 #beaker.session.data_dir = %(here)s/data/sessions
48
31
49
32
50 ##Type of storage used for the session, current types are
33 ################################################################################
51 ##“dbm”, “file”, “memcached”, “database”, and “memory”.
34 ## WARNING: *THE LINE BELOW MUST BE UNCOMMENTED ON A PRODUCTION ENVIRONMENT* ##
52 ##The storage uses the Container API that is also used by the cache system.
35 ## Debug mode will enable the interactive debugging tool, allowing ANYONE to ##
53 beaker.session.type = memory
36 ## execute malicious code after an exception is raised. ##
54
37 ################################################################################
55 ##if db or memcached is used
56 ##you have to use
57 #beaker.session.url =
58 #beaker.session.table_name =
59
60 ## WARNING: *THE LINE BELOW MUST BE UNCOMMENTED ON A PRODUCTION ENVIRONMENT*
61 ## Debug mode will enable the interactive debugging tool, allowing ANYONE to
62 ## execute malicious code after an exception is raised.
63 set debug = false
38 set debug = false
64
39
65 ##dozer logging
40 ################################
66 #logview.sqlalchemy = #faa
41 ### LOGGING CONFIGURATION ####
67 #logview.pylons.templating = #bfb
42 ################################
68 #logview.sample_app.lib = #aaa
69
70 # Logging configuration
71 [loggers]
43 [loggers]
72 keys = root, routes, pylons_app
44 keys = root, routes, pylons_app, sqlalchemy
73
45
74 [handlers]
46 [handlers]
75 keys = console,file_handler
47 keys = console
76
48
77 [formatters]
49 [formatters]
78 keys = generic
50 keys = generic
79
51
52 #############
80 ## LOGGERS ##
53 ## LOGGERS ##
54 #############
81 [logger_root]
55 [logger_root]
82 level = DEBUG
56 level = INFO
83 handlers = file_handler
57 handlers = console
84
58
85 [logger_routes]
59 [logger_routes]
86 level = INFO
60 level = INFO
87 handlers = file_handler
61 handlers = console
88 qualname = routes.middleware
62 qualname = routes.middleware
89 # "level = DEBUG" logs the route matched and routing variables.
63 # "level = DEBUG" logs the route matched and routing variables.
90
64
91 [logger_pylons_app]
65 [logger_pylons_app]
92 level = DEBUG
66 level = DEBUG
93 handlers = file_handler
67 handlers = console
94 qualname = pylons_app
68 qualname = pylons_app
95
69
96
70
71 [logger_sqlalchemy]
72 level = DEBUG
73 handlers = console
74 qualname = sqlalchemy.engine
75
76 ##############
97 ## HANDLERS ##
77 ## HANDLERS ##
78 ##############
98
79
99 [handler_console]
80 [handler_console]
100 class = StreamHandler
81 class = StreamHandler
@@ -102,13 +83,9 b' args = (sys.stderr,)'
102 level = NOTSET
83 level = NOTSET
103 formatter = generic
84 formatter = generic
104
85
105 [handler_file_handler]
86 ################
106 class = FileHandler
107 args = ('./pylons_app.log','a')
108 level = NOTSET
109 formatter = generic
110
111 ## FORMATTERS ##
87 ## FORMATTERS ##
88 ################
112
89
113 [formatter_generic]
90 [formatter_generic]
114 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
@@ -1,9 +1,11 b''
1 """Pylons environment configuration"""
1 """Pylons environment configuration"""
2 import logging
2 import logging
3 import os
3 import os
4 from pylons import config
4
5 from mako.lookup import TemplateLookup
5 from mako.lookup import TemplateLookup
6 from pylons.error import handle_mako_error
6 from pylons.error import handle_mako_error
7 from pylons import config
8
7 import pylons_app.lib.app_globals as app_globals
9 import pylons_app.lib.app_globals as app_globals
8 import pylons_app.lib.helpers
10 import pylons_app.lib.helpers
9 from pylons_app.config.routing import make_map
11 from pylons_app.config.routing import make_map
@@ -34,11 +36,9 b' def load_environment(global_conf, app_co'
34 directories = paths['templates'],
36 directories = paths['templates'],
35 error_handler = handle_mako_error,
37 error_handler = handle_mako_error,
36 module_directory = os.path.join(app_conf['cache_dir'], 'templates'),
38 module_directory = os.path.join(app_conf['cache_dir'], 'templates'),
37 input_encoding = 'utf-8', default_filters = ['escape'],
39 input_encoding = 'utf-8', output_encoding = 'utf-8',
38 imports = ['from webhelpers.html import escape'])
40 imports = ['from webhelpers.html import escape'],
39
41 default_filters = ['escape'])
40 # Customize templating options via this variable
41 tmpl_options = config['buffet.template_options']
42
42
43 # CONFIGURATION OPTIONS HERE (note: all config options will override
43 # CONFIGURATION OPTIONS HERE (note: all config options will override
44 # any Pylons config options)
44 # any Pylons config options)
@@ -8,10 +8,11 b' 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
12 from pylons_app.config.environment import load_environment
11 from pylons_app.config.environment import load_environment
13
12
14 def make_app(global_conf, full_stack = True, static_files = True, **app_conf):
13
14
15 def make_app(global_conf, full_stack = True, **app_conf):
15 """Create a Pylons WSGI application and return it
16 """Create a Pylons WSGI application and return it
16
17
17 ``global_conf``
18 ``global_conf``
@@ -19,14 +20,10 b' def make_app(global_conf, full_stack = T'
19 the [DEFAULT] section of the Paste ini file.
20 the [DEFAULT] section of the Paste ini file.
20
21
21 ``full_stack``
22 ``full_stack``
22 Whether this application provides a full WSGI stack (by default,
23 Whether or not this application provides a full WSGI stack (by
23 meaning it handles its own exceptions and errors). Disable
24 default, meaning it handles its own exceptions and errors).
24 full_stack when this application is "managed" by another WSGI
25 Disable full_stack when this application is "managed" by
25 middleware.
26 another WSGI middleware.
26
27 ``static_files``
28 Whether this application serves its own static files; disable
29 when another web server is responsible for serving them.
30
27
31 ``app_conf``
28 ``app_conf``
32 The application's local configuration. Normally specified in
29 The application's local configuration. Normally specified in
@@ -40,12 +37,10 b' def make_app(global_conf, full_stack = T'
40 # The Pylons WSGI app
37 # The Pylons WSGI app
41 app = PylonsApp()
38 app = PylonsApp()
42
39
40 # CUSTOM MIDDLEWARE HERE (filtered by error handling middlewares)
41
43 # Routing/Session/Cache Middleware
42 # Routing/Session/Cache Middleware
44 app = RoutesMiddleware(app, config['routes.map'])
43 app = RoutesMiddleware(app, config['routes.map'])
45 app = SessionMiddleware(app, config)
46 app = CacheMiddleware(app, config)
47
48 # CUSTOM MIDDLEWARE HERE (filtered by error handling middlewares)
49
44
50 if asbool(full_stack):
45 if asbool(full_stack):
51 # Handle Python exceptions
46 # Handle Python exceptions
@@ -61,14 +56,9 b' def make_app(global_conf, full_stack = T'
61 # Establish the Registry for this application
56 # Establish the Registry for this application
62 app = RegistryManager(app)
57 app = RegistryManager(app)
63
58
64 if asbool(static_files):
59 # Static files (If running in production, and Apache or another web
65 # Serve static files
60 # server is handling this static content, remove the following 3 lines)
66 static_app = StaticURLParser(config['pylons.paths']['static_files'])
61 static_app = StaticURLParser(config['pylons.paths']['static_files'])
67 app = Cascade([static_app, app])
62 app = Cascade([static_app, app])
63 return app
68
64
69 #dozer debug
70 if asbool(config['debug']):
71 from dozer import Logview
72 app = Logview(app, config)
73
74 return app
@@ -20,7 +20,7 b' class HgController(BaseController):'
20 return g.hgapp(request.environ, self.start_response)
20 return g.hgapp(request.environ, self.start_response)
21
21
22 def add_repo(self, new_repo):
22 def add_repo(self, new_repo):
23 tmpl = '''
23 tmpl = u'''
24 <html>
24 <html>
25 <body>
25 <body>
26 %(msg)s%(new_repo)s!<br \>
26 %(msg)s%(new_repo)s!<br \>
@@ -43,8 +43,8 b' class HgController(BaseController):'
43 return [tmpl % ({'new_repo':new_repo, 'msg':'added repo: '})]
43 return [tmpl % ({'new_repo':new_repo, 'msg':'added repo: '})]
44
44
45 def _check_repo(self, repo_name):
45 def _check_repo(self, repo_name):
46 p = os.path.dirname(__file__)
46 p = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
47 config_path = os.path.join(p, '../..', 'hgwebdir.config')
47 config_path = os.path.join(p, 'hgwebdir.config')
48
48
49 cp = ConfigParser()
49 cp = ConfigParser()
50
50
General Comments 0
You need to be logged in to leave comments. Login now