changeset 12:5f30a6d558dc

Added pylons manage script fix the configs for zip archives some other minot changes.
author Marcin Kuzminski
date Sat, 20 Feb 2010 17:51:51 +0100
parents 92b070bb061d
children b6b3533ad63c
files development.ini hgwebdir.config production.ini pylons-manage pylons_app/config/environment.py pylons_app/config/middleware.py pylons_app/controllers/hg.py
diffstat 7 files changed, 132 insertions(+), 158 deletions(-) [+]
line wrap: on
line diff
--- a/development.ini	Sat Feb 20 14:37:29 2010 +0100
+++ b/development.ini	Sat Feb 20 17:51:51 2010 +0100
@@ -1,18 +1,16 @@
-########################################################################
-##
-## pylons_app - Pylons development environment configuration
-##
-## The %(here)s variable will be replaced with the parent directory of this file
-##
-[exe]
-command = serve
-daemon = false
-user = nobody
-group = nobody
+################################################################################
+################################################################################
+# pylons_app - Pylons environment configuration                                #
+#                                                                              # 
+# The %(here)s variable will be replaced with the parent directory of this file#
+################################################################################
 
 [DEFAULT]
 debug = true
-## Uncomment and replace with the address which should receive any error reports
+############################################
+## Uncomment and replace with the address ##
+## which should receive any error reports ##
+############################################
 email_to = marcin.kuzminski@etelko.pl
 smtp_server = localhost
 error_email_from = paste_error@localhost
@@ -20,79 +18,62 @@
 [server:main]
 use = egg:Paste#http
 host = 127.0.0.1
-port = 8001
+port = 5000
 
 [app:main]
 use = egg:pylons_app
 full_stack = true
-static_files = false
-##default lang
+static_files = true
 lang=en
-
 cache_dir = %(here)s/data
-beaker.session.key = pylons_app
-beaker.session.secret = #@^^F&VWUDCT%@$#WR^@&*IWEKF
-beaker.session.timeout = 3600
 
-##auto save the session to not to use .save()
-beaker.session.auto = True
-
-##true exire at browser close
-#beaker.session.cookie_expires = 3600
-
-## If you'd like to fine-tune the individual locations of the cache data dirs
-## for the Cache data, or the Session saves, un-comment the desired settings
-## here:
-#beaker.cache.data_dir = %(here)s/data/cache
-#beaker.session.data_dir = %(here)s/data/sessions
+################################################################################
+## WARNING: *THE LINE BELOW MUST BE UNCOMMENTED ON A PRODUCTION ENVIRONMENT*  ##
+## Debug mode will enable the interactive debugging tool, allowing ANYONE to  ##
+## execute malicious code after an exception is raised.                       ##
+################################################################################
+#set debug = false
 
 
-##Type of storage used for the session, current types are 
-##“dbm”, “file”, “memcached”, “database”, and “memory”. 
-##The storage uses the Container API that is also used by the cache system.
-beaker.session.type = memory
-
-##if db or memcached is used
-##you have to use
-#beaker.session.url =
-#beaker.session.table_name =
-
-## WARNING: *THE LINE BELOW MUST BE UNCOMMENTED ON A PRODUCTION ENVIRONMENT*
-## Debug mode will enable the interactive debugging tool, allowing ANYONE to
-## execute malicious code after an exception is raised.
-#set debug = false
-
-##dozer logging
-logview.pylons.templating = #bfb
-logview.sample_app.lib = #aaa
-
-# Logging configuration
+################################
+### LOGGING CONFIGURATION   ####
+################################
 [loggers]
-keys = root, routes, pylons_app
+keys = root, routes, pylons_app, sqlalchemy
 
 [handlers]
-keys = console,file_handler
+keys = console
 
 [formatters]
 keys = generic
 
+#############
 ## LOGGERS ##
+#############
 [logger_root]
-level = DEBUG
-handlers = console, file_handler
+level = INFO
+handlers = console
 
 [logger_routes]
-level = DEBUG
+level = INFO
 handlers = console
 qualname = routes.middleware
 # "level = DEBUG" logs the route matched and routing variables.
 
 [logger_pylons_app]
 level = DEBUG
-handlers = console,file_handler
+handlers = console
 qualname = pylons_app
 
+
+[logger_sqlalchemy]
+level = DEBUG
+handlers = console
+qualname = sqlalchemy.engine
+
+##############
 ## HANDLERS ##
+##############
 
 [handler_console]
 class = StreamHandler
@@ -100,13 +81,9 @@
 level = NOTSET
 formatter = generic
 
-[handler_file_handler]
-class = FileHandler
-args = ('./pylons_app.log','a')
-level = NOTSET
-formatter = generic
-
+################
 ## FORMATTERS ##
+################
 
 [formatter_generic]
 format = %(asctime)s,%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s
--- a/hgwebdir.config	Sat Feb 20 14:37:29 2010 +0100
+++ b/hgwebdir.config	Sat Feb 20 17:51:51 2010 +0100
@@ -11,9 +11,8 @@
 contact = marcin.kuzminski@etelko.pl
 allow_archive = gz zip bz2
 allow_push = *
-#style = monoblue
 style = gitweb
-Spygments_style = trac
+pygments_style = trac
 staticurl = /static
 baseurl = /
 
--- a/production.ini	Sat Feb 20 14:37:29 2010 +0100
+++ b/production.ini	Sat Feb 20 17:51:51 2010 +0100
@@ -1,18 +1,16 @@
-########################################################################
-##
-## pylons_app - Pylons development environment configuration
-##
-## The %(here)s variable will be replaced with the parent directory of this file
-##
-[exe]
-command = serve
-daemon = false
-user = nobody
-group = nobody
+################################################################################
+################################################################################
+# pylons_app - Pylons environment configuration                                #
+#                                                                              # 
+# The %(here)s variable will be replaced with the parent directory of this file#
+################################################################################
 
 [DEFAULT]
 debug = true
-## Uncomment and replace with the address which should receive any error reports
+############################################
+## Uncomment and replace with the address ##
+## which should receive any error reports ##
+############################################
 email_to = marcin.kuzminski@etelko.pl
 smtp_server = localhost
 error_email_from = paste_error@localhost
@@ -24,77 +22,60 @@
 
 [app:main]
 use = egg:pylons_app
-full_stack = true
-static_files = false
-##default lang
+full_stack = false
+static_files = true
+#default lang
 lang=en
 
 cache_dir = %(here)s/data
-beaker.session.key = pylons_app
-beaker.session.secret = #@^^F&VWUDCT%@$#WR^@&*IWEKF
-beaker.session.timeout = 3600
-
-##auto save the session to not to use .save()
-beaker.session.auto = True
-
-##true exire at browser close
-#beaker.session.cookie_expires = 3600
-
-## If you'd like to fine-tune the individual locations of the cache data dirs
-## for the Cache data, or the Session saves, un-comment the desired settings
-## here:
-#beaker.cache.data_dir = %(here)s/data/cache
-#beaker.session.data_dir = %(here)s/data/sessions
 
 
-##Type of storage used for the session, current types are 
-##“dbm”, “file”, “memcached”, “database”, and “memory”. 
-##The storage uses the Container API that is also used by the cache system.
-beaker.session.type = memory
-
-##if db or memcached is used
-##you have to use
-#beaker.session.url =
-#beaker.session.table_name =
-
-## WARNING: *THE LINE BELOW MUST BE UNCOMMENTED ON A PRODUCTION ENVIRONMENT*
-## Debug mode will enable the interactive debugging tool, allowing ANYONE to
-## execute malicious code after an exception is raised.
+################################################################################
+## WARNING: *THE LINE BELOW MUST BE UNCOMMENTED ON A PRODUCTION ENVIRONMENT*  ##
+## Debug mode will enable the interactive debugging tool, allowing ANYONE to  ##
+## execute malicious code after an exception is raised.                       ##
+################################################################################
 set debug = false
 
-##dozer logging
-#logview.sqlalchemy = #faa
-#logview.pylons.templating = #bfb
-#logview.sample_app.lib = #aaa
-
-# Logging configuration
+################################
+### LOGGING CONFIGURATION   ####
+################################
 [loggers]
-keys = root, routes, pylons_app
+keys = root, routes, pylons_app, sqlalchemy
 
 [handlers]
-keys = console,file_handler
+keys = console
 
 [formatters]
 keys = generic
 
+#############
 ## LOGGERS ##
+#############
 [logger_root]
-level = DEBUG
-handlers = file_handler
+level = INFO
+handlers = console
 
 [logger_routes]
 level = INFO
-handlers = file_handler
+handlers = console
 qualname = routes.middleware
 # "level = DEBUG" logs the route matched and routing variables.
 
 [logger_pylons_app]
 level = DEBUG
-handlers = file_handler
+handlers = console
 qualname = pylons_app
 
 
+[logger_sqlalchemy]
+level = DEBUG
+handlers = console
+qualname = sqlalchemy.engine
+
+##############
 ## HANDLERS ##
+##############
 
 [handler_console]
 class = StreamHandler
@@ -102,13 +83,9 @@
 level = NOTSET
 formatter = generic
 
-[handler_file_handler]
-class = FileHandler
-args = ('./pylons_app.log','a')
-level = NOTSET
-formatter = generic
-
+################
 ## FORMATTERS ##
+################
 
 [formatter_generic]
 format = %(asctime)s,%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pylons-manage	Sat Feb 20 17:51:51 2010 +0100
@@ -0,0 +1,31 @@
+#!/bin/sh -e
+### BEGIN INIT INFO
+# Provides:         pylons-manage          
+# Required-Start:    $all
+# Required-Stop:     $all
+# Default-Start:     2 3 4 5
+# Default-Stop:      0 1 6
+# Short-Description: starts pylons app
+# Description:       starts pylons app
+### END INIT INFO
+
+project_name=hg_app
+conf_name=development.ini
+project_path=/home/marcink/python_workspace/$project_name
+virt_python=/home/marcink/virt_python
+
+cd $project_path
+case "$1" in
+  start)
+    $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
+    ;;
+  stop)
+    $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
+    ;;
+  restart)
+    $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
+    ;;
+  *)
+    echo "Usage: $0 {start|stop|restart}"
+    exit 1
+esac
\ No newline at end of file
--- a/pylons_app/config/environment.py	Sat Feb 20 14:37:29 2010 +0100
+++ b/pylons_app/config/environment.py	Sat Feb 20 17:51:51 2010 +0100
@@ -1,9 +1,11 @@
 """Pylons environment configuration"""
 import logging
 import os
-from pylons import config
+
 from mako.lookup import TemplateLookup
 from pylons.error import handle_mako_error
+from pylons import config
+
 import pylons_app.lib.app_globals as app_globals
 import pylons_app.lib.helpers
 from pylons_app.config.routing import make_map
@@ -34,11 +36,9 @@
         directories = paths['templates'],
         error_handler = handle_mako_error,
         module_directory = os.path.join(app_conf['cache_dir'], 'templates'),
-        input_encoding = 'utf-8', default_filters = ['escape'],
-        imports = ['from webhelpers.html import escape'])
-
-    # Customize templating options via this variable
-    tmpl_options = config['buffet.template_options']
+        input_encoding = 'utf-8', output_encoding = 'utf-8',
+        imports = ['from webhelpers.html import escape'],
+        default_filters = ['escape'])
 
     # CONFIGURATION OPTIONS HERE (note: all config options will override
     # any Pylons config options)
--- a/pylons_app/config/middleware.py	Sat Feb 20 14:37:29 2010 +0100
+++ b/pylons_app/config/middleware.py	Sat Feb 20 17:51:51 2010 +0100
@@ -8,10 +8,11 @@
 from pylons.middleware import ErrorHandler, StatusCodeRedirect
 from pylons.wsgiapp import PylonsApp
 from routes.middleware import RoutesMiddleware
-
 from pylons_app.config.environment import load_environment
 
-def make_app(global_conf, full_stack = True, static_files = True, **app_conf):
+
+
+def make_app(global_conf, full_stack = True, **app_conf):
     """Create a Pylons WSGI application and return it
 
     ``global_conf``
@@ -19,14 +20,10 @@
         the [DEFAULT] section of the Paste ini file.
 
     ``full_stack``
-        Whether this application provides a full WSGI stack (by default,
-        meaning it handles its own exceptions and errors). Disable
-        full_stack when this application is "managed" by another WSGI
-        middleware.
-
-    ``static_files``
-        Whether this application serves its own static files; disable
-        when another web server is responsible for serving them.
+        Whether or not this application provides a full WSGI stack (by
+        default, meaning it handles its own exceptions and errors).
+        Disable full_stack when this application is "managed" by
+        another WSGI middleware.
 
     ``app_conf``
         The application's local configuration. Normally specified in
@@ -40,12 +37,10 @@
     # The Pylons WSGI app
     app = PylonsApp()
 
+    # CUSTOM MIDDLEWARE HERE (filtered by error handling middlewares)
+
     # Routing/Session/Cache Middleware
     app = RoutesMiddleware(app, config['routes.map'])
-    app = SessionMiddleware(app, config)
-    app = CacheMiddleware(app, config)
-
-    # CUSTOM MIDDLEWARE HERE (filtered by error handling middlewares)
 
     if asbool(full_stack):
         # Handle Python exceptions
@@ -61,14 +56,9 @@
     # Establish the Registry for this application
     app = RegistryManager(app)
 
-    if asbool(static_files):
-        # Serve static files
-        static_app = StaticURLParser(config['pylons.paths']['static_files'])
-        app = Cascade([static_app, app])
+    # Static files (If running in production, and Apache or another web
+    # server is handling this static content, remove the following 3 lines)
+    static_app = StaticURLParser(config['pylons.paths']['static_files'])
+    app = Cascade([static_app, app])
+    return app
 
-    #dozer debug
-    if asbool(config['debug']):
-        from dozer import Logview
-        app = Logview(app, config)
-
-    return app
--- a/pylons_app/controllers/hg.py	Sat Feb 20 14:37:29 2010 +0100
+++ b/pylons_app/controllers/hg.py	Sat Feb 20 17:51:51 2010 +0100
@@ -20,7 +20,7 @@
         return g.hgapp(request.environ, self.start_response)
 
     def add_repo(self, new_repo):
-        tmpl = '''
+        tmpl = u'''
                   <html>
                     <body>
                         %(msg)s%(new_repo)s!<br \>
@@ -43,8 +43,8 @@
         return [tmpl % ({'new_repo':new_repo, 'msg':'added repo: '})]
 
     def _check_repo(self, repo_name):
-        p = os.path.dirname(__file__)
-        config_path = os.path.join(p, '../..', 'hgwebdir.config')
+        p = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
+        config_path = os.path.join(p, 'hgwebdir.config')
 
         cp = ConfigParser()