1. Andriy Kornatskyy
  2. wheezy.web

Commits

Andriy Kornatskyy  committed 351a8a2

Added configuration options for public and template demo.

  • Participants
  • Parent commits 696271e
  • Branches default

Comments (0)

Files changed (6)

File demos/public/Makefile

View file
 	$(PYTHON) src/app.py
 
 uwsgi:
-	$(ENV)/bin/uwsgi -C 777 --logto=/dev/null -p 1 \
-		-H $(ENV) --pythonpath src -s /tmp/uwsgi-test.sock \
-		-M -w app:main
+	$(ENV)/bin/uwsgi --ini development.ini
 
 gunicorn:
 	export PYTHONPATH=$$PYTHONPATH:./src ; \

File demos/public/development.ini

View file
+
+[cache-profile]
+static-enabled = True
+public-enabled = False
+
+[crypto]
+encryption-key = 4oqiKhW3qzP2EiattMt7
+validation-key = A7GfjxIBCBA3vNqvafWf
+ticket-max-age = 1200
+ticket-salt = JNbCog95cDTo1NRb7inP
+
+[mako]
+filesystem-checks = True
+module-directory = /tmp/mako_modules
+
+[uwsgi]
+wsgi = app:main
+protocol = uwsgi
+socket = /tmp/uwsgi-test.sock
+chmod-socket = 777
+umask = 000
+harakiri = 5
+optimize = O2
+master = True
+processes = 1
+virtualenv = ../../env
+pythonpath = src
+disable-logging = True
+logto = /dev/null
+no-default-app = True
+auto-procname = True
+procname-prefix = MySite-
+limit-as = 30
+limit-post = 1024
+chdir = .
+idle = 60

File demos/public/src/config.py

View file
 """
 """
 
+from ConfigParser import ConfigParser
 from datetime import timedelta
 
 from wheezy.caching import MemoryCache
 from membership.repository.mock import MembershipRepository
 
 
+config = ConfigParser()
+config.read('development.ini')
+
 cache = MemoryCache()
 cache_factory = lambda: cache
 
         duration=timedelta(minutes=15),
         vary_environ=['HTTP_ACCEPT_ENCODING'],
         namespace='static',
-        enabled=True)
+        enabled=config.getboolean('cache-profile', 'static-enabled'))
 public_cache_profile = CacheProfile(
         'server',
         duration=timedelta(minutes=15),
         vary_environ=['HTTP_ACCEPT_ENCODING'],
         vary_cookies=['_a'],
         no_store=True,
-        enabled=False)
+        enabled=config.getboolean('cache-profile', 'public-enabled'))
 
 # HTTPErrorMiddleware
 options.update({
 
 # wheezy.security.crypto.Ticket
 options.update({
-        'CRYPTO_ENCRYPTION_KEY': '4oqiKhW3qzP2EiattMt7',
-        'CRYPTO_VALIDATION_KEY': 'A7GfjxIBCBA3vNqvafWf'
+        'CRYPTO_ENCRYPTION_KEY': config.get('crypto', 'encryption-key'),
+        'CRYPTO_VALIDATION_KEY': config.get('crypto', 'validation-key')
 })
 
 # BaseHandler
             default_lang='en'),
 
         'render_template': MakoTemplate(
+            module_directory=config.get('mako', 'module-directory'),
+            filesystem_checks=config.getboolean('mako', 'filesystem-checks'),
             directories=['content/templates'],
-            filesystem_checks=False,
             cache_factory=cache_factory,
             preprocessor=[
                 widget_preprocessor,
             ]),
 
         'ticket': Ticket(
-            max_age=1200,
-            salt='JNbCog95cDTo1NRb7inP',
+            max_age=config.getint('crypto', 'ticket-max-age'),
+            salt=config.get('crypto', 'ticket-salt'),
             options=options),
 
         'AUTH_COOKIE': '_a',

File demos/template/Makefile

View file
 	$(PYTHON) src/app.py
 
 uwsgi:
-	$(ENV)/bin/uwsgi -C 777 --logto=/dev/null -p 1 \
-		-H $(ENV) --pythonpath src -s /tmp/uwsgi-test.sock \
-		-M -w app:main
+	$(ENV)/bin/uwsgi --ini development.ini
 
 gunicorn:
 	export PYTHONPATH=$$PYTHONPATH:./src ; \

File demos/template/development.ini

View file
+
+[cache-profile]
+static-enabled = True
+public-enabled = False
+
+[crypto]
+encryption-key = r0sWsYR3dHUcrPWeTcB7
+validation-key = kTrdyg9ZwcNyE6YKoPJU
+ticket-max-age = 1200
+ticket-salt = WmMFjzVbSpWlCKb6cOC4
+
+[mako]
+filesystem-checks = True
+module-directory = /tmp/mako_modules
+
+[uwsgi]
+wsgi = app:main
+protocol = uwsgi
+socket = /tmp/uwsgi-test.sock
+chmod-socket = 777
+umask = 000
+harakiri = 5
+optimize = O2
+master = True
+processes = 1
+virtualenv = ../../env
+pythonpath = src
+disable-logging = True
+logto = /dev/null
+no-default-app = True
+auto-procname = True
+procname-prefix = MySite-
+limit-as = 30
+limit-post = 1024
+chdir = .
+idle = 60

File demos/template/src/config.py

View file
 """
 """
 
+from ConfigParser import ConfigParser
 from datetime import timedelta
 
 from wheezy.caching import MemoryCache
 from membership.repository.mock import MembershipRepository
 
 
+config = ConfigParser()
+config.read('development.ini')
+
 cache = MemoryCache()
 cache_factory = lambda: cache
 
         duration=timedelta(minutes=15),
         vary_environ=['HTTP_ACCEPT_ENCODING'],
         namespace='static',
-        enabled=True)
+        enabled=config.getboolean('cache-profile', 'static-enabled'))
 public_cache_profile = CacheProfile(
         'server',
         duration=timedelta(minutes=15),
         vary_environ=['HTTP_ACCEPT_ENCODING'],
         vary_cookies=['_a'],
         no_store=True,
-        enabled=False)
+        enabled=config.getboolean('cache-profile', 'public-enabled'))
 
 # HTTPErrorMiddleware
 options.update({
 
 # wheezy.security.crypto.Ticket
 options.update({
-        'CRYPTO_ENCRYPTION_KEY': 'r0sWsYR3dHUcrPWeTcB7',
-        'CRYPTO_VALIDATION_KEY': 'kTrdyg9ZwcNyE6YKoPJU'
+        'CRYPTO_ENCRYPTION_KEY': config.get('crypto', 'encryption-key'),
+        'CRYPTO_VALIDATION_KEY': config.get('crypto', 'validation-key')
 })
 
 # BaseHandler
             default_lang='en'),
 
         'render_template': MakoTemplate(
+            module_directory=config.get('mako', 'module-directory'),
+            filesystem_checks=config.getboolean('mako', 'filesystem-checks'),
             directories=['content/templates'],
-            filesystem_checks=False,
             cache_factory=cache_factory,
             preprocessor=[
                 widget_preprocessor,
             ]),
 
         'ticket': Ticket(
-            max_age=1200,
-            salt='WmMFjzVbSpWlCKb6cOC4',
+            max_age=config.getint('crypto', 'ticket-max-age'),
+            salt=config.get('crypto', 'ticket-salt'),
             options=options),
 
         'AUTH_COOKIE': '_a',