summaryrefslogtreecommitdiff
path: root/docs/narr/MyProject
diff options
context:
space:
mode:
authorChris McDonough <chrism@plope.com>2011-11-12 20:05:48 -0500
committerChris McDonough <chrism@plope.com>2011-11-12 20:05:48 -0500
commit8595a7757b9347597e5664cc2c631f494825103e (patch)
tree4d4351aa77265658920f5353228a46545d849737 /docs/narr/MyProject
parentc7b6c1373ff3c971012964ad2dcab069f2548fb2 (diff)
downloadpyramid-8595a7757b9347597e5664cc2c631f494825103e.tar.gz
pyramid-8595a7757b9347597e5664cc2c631f494825103e.tar.bz2
pyramid-8595a7757b9347597e5664cc2c631f494825103e.zip
make myproject project relocatable (as per Ken's changes)
Diffstat (limited to 'docs/narr/MyProject')
-rw-r--r--docs/narr/MyProject/myproject/__init__.py8
-rw-r--r--docs/narr/MyProject/myproject/tests.py2
-rw-r--r--docs/narr/MyProject/myproject/views.py4
3 files changed, 8 insertions, 6 deletions
diff --git a/docs/narr/MyProject/myproject/__init__.py b/docs/narr/MyProject/myproject/__init__.py
index 04e219e36..ddcdd7162 100644
--- a/docs/narr/MyProject/myproject/__init__.py
+++ b/docs/narr/MyProject/myproject/__init__.py
@@ -1,12 +1,10 @@
from pyramid.config import Configurator
-from myproject.resources import Root
+from .resources import Root
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
config = Configurator(root_factory=Root, settings=settings)
- config.add_view('myproject.views.my_view',
- context='myproject.resources.Root',
- renderer='myproject:templates/mytemplate.pt')
- config.add_static_view('static', 'myproject:static')
+ config.add_static_view('static', 'static', cache_max_age=3600)
+ config.scan()
return config.make_wsgi_app()
diff --git a/docs/narr/MyProject/myproject/tests.py b/docs/narr/MyProject/myproject/tests.py
index 5fa710278..a32165471 100644
--- a/docs/narr/MyProject/myproject/tests.py
+++ b/docs/narr/MyProject/myproject/tests.py
@@ -10,7 +10,7 @@ class ViewTests(unittest.TestCase):
testing.tearDown()
def test_my_view(self):
- from myproject.views import my_view
+ from .views import my_view
request = testing.DummyRequest()
info = my_view(request)
self.assertEqual(info['project'], 'MyProject')
diff --git a/docs/narr/MyProject/myproject/views.py b/docs/narr/MyProject/myproject/views.py
index c43b34460..5b5d230f2 100644
--- a/docs/narr/MyProject/myproject/views.py
+++ b/docs/narr/MyProject/myproject/views.py
@@ -1,2 +1,6 @@
+from pyramid.view import view_config
+from .resources import Root
+
+@view_config(context=Root, renderer='templates/mytemplate.pt')
def my_view(request):
return {'project':'MyProject'}