From 4466bb20f3dada4d7fde0aff0a49213d8eb177ab Mon Sep 17 00:00:00 2001 From: kenmanheimer Date: Tue, 8 Nov 2011 11:56:25 -0800 Subject: Convert absolute 'tutorial' package references that are from within the package to relative ones, to reduce brittleness, eg when the user names the package something other than 'tutorial'. - make imports relative - use plain relative URLs for resources (like stylesheets and images) in page templates. --- docs/tutorials/wiki/src/models/tutorial/__init__.py | 4 ++-- docs/tutorials/wiki/src/models/tutorial/templates/mytemplate.pt | 8 ++++---- docs/tutorials/wiki/src/models/tutorial/views.py | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) (limited to 'docs/tutorials/wiki/src/models') diff --git a/docs/tutorials/wiki/src/models/tutorial/__init__.py b/docs/tutorials/wiki/src/models/tutorial/__init__.py index 2d637b9de..1fbb2bedb 100644 --- a/docs/tutorials/wiki/src/models/tutorial/__init__.py +++ b/docs/tutorials/wiki/src/models/tutorial/__init__.py @@ -1,6 +1,6 @@ from pyramid.config import Configurator from pyramid_zodbconn import get_connection -from tutorial.models import appmaker +from .models import appmaker def root_factory(request): conn = get_connection(request) @@ -10,7 +10,7 @@ def main(global_config, **settings): """ This function returns a WSGI application. """ config = Configurator(root_factory=root_factory, settings=settings) - config.add_static_view('static', 'tutorial:static', cache_max_age=3600) + config.add_static_view('static', 'static', cache_max_age=3600) config.scan('tutorial') return config.make_wsgi_app() diff --git a/docs/tutorials/wiki/src/models/tutorial/templates/mytemplate.pt b/docs/tutorials/wiki/src/models/tutorial/templates/mytemplate.pt index 14b88d16a..3597c679b 100644 --- a/docs/tutorials/wiki/src/models/tutorial/templates/mytemplate.pt +++ b/docs/tutorials/wiki/src/models/tutorial/templates/mytemplate.pt @@ -5,19 +5,19 @@ - + - +
-
pyramid
+
pyramid
diff --git a/docs/tutorials/wiki/src/models/tutorial/views.py b/docs/tutorials/wiki/src/models/tutorial/views.py index 2346602c9..7c1f1d228 100644 --- a/docs/tutorials/wiki/src/models/tutorial/views.py +++ b/docs/tutorials/wiki/src/models/tutorial/views.py @@ -1,5 +1,5 @@ from pyramid.view import view_config -@view_config(renderer='tutorial:templates/mytemplate.pt') +@view_config(renderer='templates/mytemplate.pt') def my_view(request): return {'project':'tutorial'} -- cgit v1.2.3 From fa9113792da7cccf34ea05a3821fc8d2335db33a Mon Sep 17 00:00:00 2001 From: kenmanheimer Date: Thu, 10 Nov 2011 12:47:02 -0800 Subject: Convert absolute 'tutorial' package references that are from within the package to relative ones, to reduce brittleness, eg when the user names the package something other than 'tutorial'. - make imports relative - use plain relative URLs for resources (like stylesheets and images) in page templates. This is the last batch of this kind of change that I know about. I've exercised the changes (via the browser and the test target) in a package with an alternate name, 'zodbtutorial', as well as in a package with the default name, 'tutorial'. --- docs/tutorials/wiki/src/models/tutorial/tests.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'docs/tutorials/wiki/src/models') diff --git a/docs/tutorials/wiki/src/models/tutorial/tests.py b/docs/tutorials/wiki/src/models/tutorial/tests.py index 51c97a95d..9fd13a18d 100644 --- a/docs/tutorials/wiki/src/models/tutorial/tests.py +++ b/docs/tutorials/wiki/src/models/tutorial/tests.py @@ -5,7 +5,7 @@ from pyramid import testing class PageModelTests(unittest.TestCase): def _getTargetClass(self): - from tutorial.models import Page + from .models import Page return Page def _makeOne(self, data=u'some data'): @@ -14,11 +14,11 @@ class PageModelTests(unittest.TestCase): def test_constructor(self): instance = self._makeOne() self.assertEqual(instance.data, u'some data') - + class WikiModelTests(unittest.TestCase): def _getTargetClass(self): - from tutorial.models import Wiki + from .models import Wiki return Wiki def _makeOne(self): @@ -32,7 +32,7 @@ class WikiModelTests(unittest.TestCase): class AppmakerTests(unittest.TestCase): def _callFUT(self, zodb_root): - from tutorial.models import appmaker + from .models import appmaker return appmaker(zodb_root) def test_no_app_root(self): @@ -55,7 +55,7 @@ class ViewTests(unittest.TestCase): testing.tearDown() def test_my_view(self): - from tutorial.views import my_view + from .views import my_view request = testing.DummyRequest() info = my_view(request) self.assertEqual(info['project'], 'tutorial') -- cgit v1.2.3