update basiclayout and its src
| | |
| | | |
| | | A directory on disk can be turned into a Python :term:`package` by containing |
| | | an ``__init__.py`` file. Even if empty, this marks a directory as a Python |
| | | package. We use ``__init__.py`` both as a marker, indicating the directory |
| | | in which it's contained is a package, and to contain application configuration |
| | | package. We use ``__init__.py`` both as a marker, indicating the directory in |
| | | which it's contained is a package, and to contain application configuration |
| | | code. |
| | | |
| | | When you run the application using the ``pserve`` command using the |
| | | ``development.ini`` generated configuration file, the application |
| | | configuration points at a Setuptools *entry point* described as |
| | | configuration points at a setuptools *entry point* described as |
| | | ``egg:tutorial``. In our application, because the application's ``setup.py`` |
| | | file says so, this entry point happens to be the ``main`` function within the |
| | | file named ``__init__.py``. Let's take a look at the code and describe what |
| | | it does: |
| | | file named ``__init__.py``. |
| | | |
| | | .. literalinclude:: src/basiclayout/tutorial/__init__.py |
| | | :linenos: |
| | | :language: py |
| | | Open ``tutorial/__init__.py``. It should already contain the following: |
| | | |
| | | .. literalinclude:: src/basiclayout/tutorial/__init__.py |
| | | :linenos: |
| | | :language: py |
| | | |
| | | #. *Lines 1-3*. Perform some dependency imports. |
| | | |
| | |
| | | |
| | | Here is the source for ``models.py``: |
| | | |
| | | .. literalinclude:: src/basiclayout/tutorial/models.py |
| | | :linenos: |
| | | :language: py |
| | | .. literalinclude:: src/basiclayout/tutorial/models.py |
| | | :linenos: |
| | | :language: python |
| | | |
| | | #. *Lines 4-5*. The ``MyModel`` :term:`resource` class is implemented here. |
| | | Instances of this class are capable of being persisted in :term:`ZODB` |
| | |
| | | |
| | | Here is the source for ``views.py``: |
| | | |
| | | .. literalinclude:: src/basiclayout/tutorial/views.py |
| | | :linenos: |
| | | :language: py |
| | | .. literalinclude:: src/basiclayout/tutorial/views.py |
| | | :linenos: |
| | | :language: python |
| | | |
| | | Let's try to understand the components in this module: |
| | | |
| | |
| | | opposed to the tutorial :term:`package` directory) looks like this: |
| | | |
| | | .. literalinclude:: src/basiclayout/development.ini |
| | | :language: ini |
| | | :language: ini |
| | | |
| | | Note the existence of a ``[app:main]`` section which specifies our WSGI |
| | | application. Our ZODB database settings are specified as the |
| | |
| | | ### |
| | | # app configuration |
| | | # http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/environment.html |
| | | # http://docs.pylonsproject.org/projects/pyramid/en/1.7-branch/narr/environment.html |
| | | ### |
| | | |
| | | [app:main] |
| | |
| | | |
| | | [server:main] |
| | | use = egg:waitress#main |
| | | host = 0.0.0.0 |
| | | host = 127.0.0.1 |
| | | port = 6543 |
| | | |
| | | ### |
| | | # logging configuration |
| | | # http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/logging.html |
| | | # http://docs.pylonsproject.org/projects/pyramid/en/1.7-branch/narr/logging.html |
| | | ### |
| | | |
| | | [loggers] |
| | |
| | | formatter = generic |
| | | |
| | | [formatter_generic] |
| | | format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s |
| | | format = %(asctime)s %(levelname)-5.5s [%(name)s:%(lineno)s][%(threadName)s] %(message)s |
| | |
| | | ### |
| | | # app configuration |
| | | # http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/environment.html |
| | | # http://docs.pylonsproject.org/projects/pyramid/en/1.7-branch/narr/environment.html |
| | | ### |
| | | |
| | | [app:main] |
| | |
| | | |
| | | ### |
| | | # logging configuration |
| | | # http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/logging.html |
| | | # http://docs.pylonsproject.org/projects/pyramid/en/1.7-branch/narr/logging.html |
| | | ### |
| | | |
| | | [loggers] |
| | |
| | | formatter = generic |
| | | |
| | | [formatter_generic] |
| | | format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s |
| | | format = %(asctime)s %(levelname)-5.5s [%(name)s:%(lineno)s][%(threadName)s] %(message)s |
| | |
| | | 'waitress', |
| | | ] |
| | | |
| | | testing_extras = [ |
| | | 'WebTest >= 1.3.1', # py3 compat |
| | | 'pytest', # includes virtualenv |
| | | 'pytest-cov', |
| | | ] |
| | | |
| | | setup(name='tutorial', |
| | | version='0.0', |
| | | description='tutorial', |
| | | long_description=README + '\n\n' + CHANGES, |
| | | classifiers=[ |
| | | "Programming Language :: Python", |
| | | "Framework :: Pyramid", |
| | | "Topic :: Internet :: WWW/HTTP", |
| | | "Topic :: Internet :: WWW/HTTP :: WSGI :: Application", |
| | | ], |
| | | "Programming Language :: Python", |
| | | "Framework :: Pyramid", |
| | | "Topic :: Internet :: WWW/HTTP", |
| | | "Topic :: Internet :: WWW/HTTP :: WSGI :: Application", |
| | | ], |
| | | author='', |
| | | author_email='', |
| | | url='', |
| | |
| | | packages=find_packages(), |
| | | include_package_data=True, |
| | | zip_safe=False, |
| | | extras_require={ |
| | | 'testing': testing_extras, |
| | | }, |
| | | install_requires=requires, |
| | | tests_require=requires, |
| | | test_suite="tutorial", |
| | | entry_points="""\ |
| | | [paste.app_factory] |
| | | main = tutorial:main |
| | |
| | | |
| | | |
| | | def appmaker(zodb_root): |
| | | if not 'app_root' in zodb_root: |
| | | if 'app_root' not in zodb_root: |
| | | app_root = MyModel() |
| | | zodb_root['app_root'] = app_root |
| | | import transaction |
| | |
| | | color: #f2b7bd; |
| | | font-weight: 400; |
| | | } |
| | | .starter-template .links ul li a, a { |
| | | color: #f2b7bd; |
| | | text-decoration: underline; |
| | | } |
| | | .starter-template .links ul li a:hover, a:hover { |
| | | .starter-template .links ul li a { |
| | | color: #ffffff; |
| | | } |
| | | .starter-template .links ul li a:hover { |
| | | text-decoration: underline; |
| | | } |
| | | .starter-template .links ul li .icon-muted { |
| | |
| | | <div class="col-md-10"> |
| | | <div class="content"> |
| | | <h1><span class="font-semi-bold">Pyramid</span> <span class="smaller">ZODB scaffold</span></h1> |
| | | <p class="lead">Welcome to <span class="font-normal">${project}</span>, an application generated by<br>the <span class="font-normal">Pyramid Web Framework</span>.</p> |
| | | <p class="lead">Welcome to <span class="font-normal">${project}</span>, an application generated by<br>the <span class="font-normal">Pyramid Web Framework 1.7</span>.</p> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <div class="row"> |
| | | <div class="links"> |
| | | <ul> |
| | | <li><i class="glyphicon glyphicon-bookmark icon-muted"></i><a href="http://docs.pylonsproject.org/projects/pyramid/en/latest/">Docs</a></li> |
| | | <li class="current-version">Generated by v1.7</li> |
| | | <li><i class="glyphicon glyphicon-bookmark icon-muted"></i><a href="http://docs.pylonsproject.org/projects/pyramid/en/1.7-branch/">Docs</a></li> |
| | | <li><i class="glyphicon glyphicon-cog icon-muted"></i><a href="https://github.com/Pylons/pyramid">Github Project</a></li> |
| | | <li><i class="glyphicon glyphicon-globe icon-muted"></i><a href="irc://irc.freenode.net#pyramid">IRC Channel</a></li> |
| | | <li><i class="glyphicon glyphicon-home icon-muted"></i><a href="http://pylonsproject.org">Pylons Project</a></li> |
| | |
| | | |
| | | from pyramid import testing |
| | | |
| | | |
| | | class ViewTests(unittest.TestCase): |
| | | def setUp(self): |
| | | self.config = testing.setUp() |