From f1103c8e357de80fd2fb58d101138a3f20dd8e9b Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Thu, 4 Nov 2010 01:03:47 -0400 Subject: make starter imperative; add new starter_zcml paster template --- pyramid/paster.py | 5 ++ .../starter/+package+/__init__.py_tmpl | 6 +- .../starter/+package+/configure.zcml | 17 ----- .../starter_zcml/+package+/__init__.py_tmpl | 16 +++++ .../starter_zcml/+package+/configure.zcml | 17 +++++ .../starter_zcml/+package+/models.py | 7 +++ .../starter_zcml/+package+/templates/mytemplate.pt | 69 ++++++++++++++++++++ .../+package+/templates/static/favicon.ico | Bin 0 -> 1406 bytes .../+package+/templates/static/logo.png | Bin 0 -> 6641 bytes .../+package+/templates/static/pylons.css | 70 +++++++++++++++++++++ .../starter_zcml/+package+/tests.py_tmpl | 20 ++++++ .../starter_zcml/+package+/views.py_tmpl | 2 + .../paster_templates/starter_zcml/CHANGES.txt_tmpl | 4 ++ .../paster_templates/starter_zcml/README.txt_tmpl | 4 ++ .../starter_zcml/development.ini_tmpl | 15 +++++ .../paster_templates/starter_zcml/setup.cfg_tmpl | 27 ++++++++ .../paster_templates/starter_zcml/setup.py_tmpl | 36 +++++++++++ setup.py | 1 + 18 files changed, 297 insertions(+), 19 deletions(-) delete mode 100644 pyramid/paster_templates/starter/+package+/configure.zcml create mode 100644 pyramid/paster_templates/starter_zcml/+package+/__init__.py_tmpl create mode 100644 pyramid/paster_templates/starter_zcml/+package+/configure.zcml create mode 100644 pyramid/paster_templates/starter_zcml/+package+/models.py create mode 100644 pyramid/paster_templates/starter_zcml/+package+/templates/mytemplate.pt create mode 100644 pyramid/paster_templates/starter_zcml/+package+/templates/static/favicon.ico create mode 100644 pyramid/paster_templates/starter_zcml/+package+/templates/static/logo.png create mode 100644 pyramid/paster_templates/starter_zcml/+package+/templates/static/pylons.css create mode 100644 pyramid/paster_templates/starter_zcml/+package+/tests.py_tmpl create mode 100644 pyramid/paster_templates/starter_zcml/+package+/views.py_tmpl create mode 100644 pyramid/paster_templates/starter_zcml/CHANGES.txt_tmpl create mode 100644 pyramid/paster_templates/starter_zcml/README.txt_tmpl create mode 100644 pyramid/paster_templates/starter_zcml/development.ini_tmpl create mode 100644 pyramid/paster_templates/starter_zcml/setup.cfg_tmpl create mode 100644 pyramid/paster_templates/starter_zcml/setup.py_tmpl diff --git a/pyramid/paster.py b/pyramid/paster.py index a1e895fcf..e41fb244b 100644 --- a/pyramid/paster.py +++ b/pyramid/paster.py @@ -14,6 +14,11 @@ class StarterProjectTemplate(Template): summary = 'pyramid starter project' template_renderer = staticmethod(paste_script_template_renderer) +class StarterZCMLProjectTemplate(Template): + _template_dir = 'paster_templates/starter_zcml' + summary = 'pyramid starter project (ZCML)' + template_renderer = staticmethod(paste_script_template_renderer) + class ZODBProjectTemplate(Template): _template_dir = 'paster_templates/zodb' summary = 'pyramid ZODB starter project' diff --git a/pyramid/paster_templates/starter/+package+/__init__.py_tmpl b/pyramid/paster_templates/starter/+package+/__init__.py_tmpl index a4e3c1d6e..715753c72 100644 --- a/pyramid/paster_templates/starter/+package+/__init__.py_tmpl +++ b/pyramid/paster_templates/starter/+package+/__init__.py_tmpl @@ -7,10 +7,12 @@ def app(global_config, **settings): It is usually called by the PasteDeploy framework during ``paster serve``. """ - zcml_file = settings.get('configure_zcml', 'configure.zcml') config = Configurator(root_factory=get_root, settings=settings) config.begin() - config.load_zcml(zcml_file) + config.add_view('{{package}}.views.my_view', + context='{{package}}.models.MyModel', + renderer='{{package}}:templates/mytemplate.pt') + config.add_static_view('static', '{{package}}:templates/static') config.end() return config.make_wsgi_app() diff --git a/pyramid/paster_templates/starter/+package+/configure.zcml b/pyramid/paster_templates/starter/+package+/configure.zcml deleted file mode 100644 index 29d577d3e..000000000 --- a/pyramid/paster_templates/starter/+package+/configure.zcml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - diff --git a/pyramid/paster_templates/starter_zcml/+package+/__init__.py_tmpl b/pyramid/paster_templates/starter_zcml/+package+/__init__.py_tmpl new file mode 100644 index 000000000..a4e3c1d6e --- /dev/null +++ b/pyramid/paster_templates/starter_zcml/+package+/__init__.py_tmpl @@ -0,0 +1,16 @@ +from pyramid.configuration import Configurator +from {{package}}.models import get_root + +def app(global_config, **settings): + """ This function returns a WSGI application. + + It is usually called by the PasteDeploy framework during + ``paster serve``. + """ + zcml_file = settings.get('configure_zcml', 'configure.zcml') + config = Configurator(root_factory=get_root, settings=settings) + config.begin() + config.load_zcml(zcml_file) + config.end() + return config.make_wsgi_app() + diff --git a/pyramid/paster_templates/starter_zcml/+package+/configure.zcml b/pyramid/paster_templates/starter_zcml/+package+/configure.zcml new file mode 100644 index 000000000..29d577d3e --- /dev/null +++ b/pyramid/paster_templates/starter_zcml/+package+/configure.zcml @@ -0,0 +1,17 @@ + + + + + + + + + + diff --git a/pyramid/paster_templates/starter_zcml/+package+/models.py b/pyramid/paster_templates/starter_zcml/+package+/models.py new file mode 100644 index 000000000..75dec7505 --- /dev/null +++ b/pyramid/paster_templates/starter_zcml/+package+/models.py @@ -0,0 +1,7 @@ +class MyModel(object): + pass + +root = MyModel() + +def get_root(request): + return root diff --git a/pyramid/paster_templates/starter_zcml/+package+/templates/mytemplate.pt b/pyramid/paster_templates/starter_zcml/+package+/templates/mytemplate.pt new file mode 100644 index 000000000..a5a0dd214 --- /dev/null +++ b/pyramid/paster_templates/starter_zcml/+package+/templates/mytemplate.pt @@ -0,0 +1,69 @@ + + + + The Pyramid Web Application Development Framework + + + + + + + + + +
+
+ +

+ Welcome to ${project}, an application generated by
+ the Pyramid web application development framework. +

+
+
+
+
+
+

Search Pyramid documentation

+
+ + +
+
+ +
+
+ + + \ No newline at end of file diff --git a/pyramid/paster_templates/starter_zcml/+package+/templates/static/favicon.ico b/pyramid/paster_templates/starter_zcml/+package+/templates/static/favicon.ico new file mode 100644 index 000000000..71f837c9e Binary files /dev/null and b/pyramid/paster_templates/starter_zcml/+package+/templates/static/favicon.ico differ diff --git a/pyramid/paster_templates/starter_zcml/+package+/templates/static/logo.png b/pyramid/paster_templates/starter_zcml/+package+/templates/static/logo.png new file mode 100644 index 000000000..88f5d9865 Binary files /dev/null and b/pyramid/paster_templates/starter_zcml/+package+/templates/static/logo.png differ diff --git a/pyramid/paster_templates/starter_zcml/+package+/templates/static/pylons.css b/pyramid/paster_templates/starter_zcml/+package+/templates/static/pylons.css new file mode 100644 index 000000000..a9c5c55c2 --- /dev/null +++ b/pyramid/paster_templates/starter_zcml/+package+/templates/static/pylons.css @@ -0,0 +1,70 @@ +html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,font,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td{margin:0;padding:0;border:0;outline:0;font-size:100%;/* 16px */ +vertical-align:baseline;background:transparent;} +body{line-height:1;} +ol,ul{list-style:none;} +blockquote,q{quotes:none;} +blockquote:before,blockquote:after,q:before,q:after{content:'';content:none;} +/* remember to define focus styles! */ +:focus{outline:0;} +/* remember to highlight inserts somehow! */ +ins{text-decoration:none;} +del{text-decoration:line-through;} +/* tables still need 'cellspacing="0"' in the markup */ +table{border-collapse:collapse;border-spacing:0;} +/* restyling */ +sub{vertical-align:sub;font-size:smaller;line-height:normal;} +sup{vertical-align:super;font-size:smaller;line-height:normal;} +/* lists */ +ul,menu,dir{display:block;list-style-type:disc;margin:1em 0;padding-left:40px;} +ol{display:block;list-style-type:decimal-leading-zero;margin:1em 0;padding-left:40px;} +li{display:list-item;} +/* nested lists have no top/bottom margins */ +ul ul,ul ol,ul dir,ul menu,ul dl,ol ul,ol ol,ol dir,ol menu,ol dl,dir ul,dir ol,dir dir,dir menu,dir dl,menu ul,menu ol,menu dir,menu menu,menu dl,dl ul,dl ol,dl dir,dl menu,dl dl{margin-top:0;margin-bottom:0;} +/* 2 deep unordered lists use a circle */ +ol ul,ul ul,menu ul,dir ul,ol menu,ul menu,menu menu,dir menu,ol dir,ul dir,menu dir,dir dir{list-style-type:circle;} +/* 3 deep (or more) unordered lists use a square */ +ol ol ul,ol ul ul,ol menu ul,ol dir ul,ol ol menu,ol ul menu,ol menu menu,ol dir menu,ol ol dir,ol ul dir,ol menu dir,ol dir dir,ul ol ul,ul ul ul,ul menu ul,ul dir ul,ul ol menu,ul ul menu,ul menu menu,ul dir menu,ul ol dir,ul ul dir,ul menu dir,ul dir dir,menu ol ul,menu ul ul,menu menu ul,menu dir ul,menu ol menu,menu ul menu,menu menu menu,menu dir menu,menu ol dir,menu ul dir,menu menu dir,menu dir dir,dir ol ul,dir ul ul,dir menu ul,dir dir ul,dir ol menu,dir ul menu,dir menu menu,dir dir menu,dir ol dir,dir ul dir,dir menu dir,dir dir dir{list-style-type:square;} +.hidden{display:none;} +p{line-height:1.5em;} +h1{font-size:1.75em;/* 28px */ +line-height:1.7em;font-family:helvetica,verdana;} +h2{font-size:1.5em;/* 24px */ +line-height:1.7em;font-family:helvetica,verdana;} +h3{font-size:1.25em;/* 20px */ +line-height:1.7em;font-family:helvetica,verdana;} +h4{font-size:1em;line-height:1.7em;font-family:helvetica,verdana;} +html,body{width:100%;height:100%;} +body{margin:0;padding:0;background-color:#ffffff;position:relative;font:16px/24px "Nobile","Lucida Grande",Lucida,Verdana,sans-serif;} +a{color:#1b61d6;text-decoration:none;} +a:hover{color:#e88f00;text-decoration:underline;} +body h1, +body h2, +body h3, +body h4, +body h5, +body h6{font-family:"Nobile","Lucida Grande",Lucida,Verdana,sans-serif;font-weight:normal;color:#144fb2;font-style:normal;} +#header,#footer{width:100%;color:#ffffff;height:40px;position:absolute;text-align:center;line-height:40px;overflow:hidden;font-size:12px;} +#header{background-color:#e88f00;top:0;font-size:14px;} +#footer{background-color:#000000;bottom:0;} +.header,.footer{width:700px;margin-right:auto;margin-left:auto;} +.wrapper{width:100%} +#top,#bottom{width:100%;} +#top{color:#888;background-color:#eee;height:300px;border-bottom:2px solid #ddd;} +#bottom{color:#222;background-color:#ffffff;} +.top,.bottom{width:700px;margin-right:auto;margin-left:auto;} +.top{padding-top:100px;} +.app-welcome{margin-top:25px;} +.app-name{color:#000000;font-weight:bold;} +.bottom{padding-top:50px;} +#left{width:325px;float:left;padding-right:25px;} +#right{width:325px;float:right;padding-left:25px;} +.align-left{text-align:left;} +.align-right{text-align:right;} +.align-center{text-align:center;} +ul.links{margin:0;padding:0;} +ul.links li{list-style-type:none;font-size:14px;} +form{border-style:none;} +fieldset{border-style:none;} +input{color:#222;border:1px solid #ccc;font-family:sans-serif;font-size:12px;line-height:16px;} +input[type=text]{} +input[type=submit]{background-color:#ddd;font-weight:bold;} diff --git a/pyramid/paster_templates/starter_zcml/+package+/tests.py_tmpl b/pyramid/paster_templates/starter_zcml/+package+/tests.py_tmpl new file mode 100644 index 000000000..2b84bee58 --- /dev/null +++ b/pyramid/paster_templates/starter_zcml/+package+/tests.py_tmpl @@ -0,0 +1,20 @@ +import unittest + +from pyramid.configuration import Configurator +from pyramid import testing + +class ViewTests(unittest.TestCase): + def setUp(self): + self.config = Configurator() + self.config.begin() + + def tearDown(self): + self.config.end() + + def test_my_view(self): + from {{package}}.views import my_view + request = testing.DummyRequest() + info = my_view(request) + self.assertEqual(info['project'], '{{project}}') + + diff --git a/pyramid/paster_templates/starter_zcml/+package+/views.py_tmpl b/pyramid/paster_templates/starter_zcml/+package+/views.py_tmpl new file mode 100644 index 000000000..12ed8832d --- /dev/null +++ b/pyramid/paster_templates/starter_zcml/+package+/views.py_tmpl @@ -0,0 +1,2 @@ +def my_view(request): + return {'project':'{{project}}'} diff --git a/pyramid/paster_templates/starter_zcml/CHANGES.txt_tmpl b/pyramid/paster_templates/starter_zcml/CHANGES.txt_tmpl new file mode 100644 index 000000000..35a34f332 --- /dev/null +++ b/pyramid/paster_templates/starter_zcml/CHANGES.txt_tmpl @@ -0,0 +1,4 @@ +0.0 +--- + +- Initial version diff --git a/pyramid/paster_templates/starter_zcml/README.txt_tmpl b/pyramid/paster_templates/starter_zcml/README.txt_tmpl new file mode 100644 index 000000000..0ddebfc3e --- /dev/null +++ b/pyramid/paster_templates/starter_zcml/README.txt_tmpl @@ -0,0 +1,4 @@ +{{project}} README + + + diff --git a/pyramid/paster_templates/starter_zcml/development.ini_tmpl b/pyramid/paster_templates/starter_zcml/development.ini_tmpl new file mode 100644 index 000000000..9bdeec1ae --- /dev/null +++ b/pyramid/paster_templates/starter_zcml/development.ini_tmpl @@ -0,0 +1,15 @@ +[DEFAULT] +debug = true + +[app:main] +use = egg:{{project}}#app +reload_templates = true +debug_authorization = false +debug_notfound = false +debug_templates = true +default_locale_name = en + +[server:main] +use = egg:Paste#http +host = 0.0.0.0 +port = 6543 diff --git a/pyramid/paster_templates/starter_zcml/setup.cfg_tmpl b/pyramid/paster_templates/starter_zcml/setup.cfg_tmpl new file mode 100644 index 000000000..5bec29823 --- /dev/null +++ b/pyramid/paster_templates/starter_zcml/setup.cfg_tmpl @@ -0,0 +1,27 @@ +[nosetests] +match=^test +nocapture=1 +cover-package={{package}} +with-coverage=1 +cover-erase=1 + +[compile_catalog] +directory = {{package}}/locale +domain = {{project}} +statistics = true + +[extract_messages] +add_comments = TRANSLATORS: +output_file = {{package}}/locale/{{project}}.pot +width = 80 + +[init_catalog] +domain = {{project}} +input_file = {{package}}/locale/{{project}}.pot +output_dir = {{package}}/locale + +[update_catalog] +domain = {{project}} +input_file = {{package}}/locale/{{project}}.pot +output_dir = {{package}}/locale +previous = true diff --git a/pyramid/paster_templates/starter_zcml/setup.py_tmpl b/pyramid/paster_templates/starter_zcml/setup.py_tmpl new file mode 100644 index 000000000..7b33177e5 --- /dev/null +++ b/pyramid/paster_templates/starter_zcml/setup.py_tmpl @@ -0,0 +1,36 @@ +import os + +from setuptools import setup, find_packages + +here = os.path.abspath(os.path.dirname(__file__)) +README = open(os.path.join(here, 'README.txt')).read() +CHANGES = open(os.path.join(here, 'CHANGES.txt')).read() + +requires = ['pyramid'] + +setup(name='{{project}}', + version='0.0', + description='{{project}}', + long_description=README + '\n\n' + CHANGES, + classifiers=[ + "Programming Language :: Python", + "Framework :: Pylons", + "Topic :: Internet :: WWW/HTTP", + "Topic :: Internet :: WWW/HTTP :: WSGI :: Application", + ], + author='', + author_email='', + url='', + keywords='web wsgi bfg pyramid pylons', + packages=find_packages(), + include_package_data=True, + zip_safe=False, + install_requires=requires, + tests_require=requires, + test_suite="{{package}}", + entry_points = """\ + [paste.app_factory] + app = {{package}}:app + """ + ) + diff --git a/setup.py b/setup.py index 226a56e17..820c622f1 100644 --- a/setup.py +++ b/setup.py @@ -80,6 +80,7 @@ setup(name='pyramid', entry_points = """\ [paste.paster_create_template] pyramid_starter=pyramid.paster:StarterProjectTemplate + pyramid_starter_zcml=pyramid.paster:StarterZCMLProjectTemplate pyramid_zodb=pyramid.paster:ZODBProjectTemplate pyramid_routesalchemy=pyramid.paster:RoutesAlchemyProjectTemplate pyramid_alchemy=pyramid.paster:AlchemyProjectTemplate -- cgit v1.2.3