Skip to content

Commit 59a76d1

Browse files
committed
Starter code for SQLAlchemy chapter.
1 parent f4522a7 commit 59a76d1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+2532
-0
lines changed

src/ch7-bootstrap/final/basic_html/.idea/inspectionProfiles/profiles_settings.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[run]
2+
source = pypi
3+
omit = pypi/test*
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
*.egg
2+
*.egg-info
3+
*.pyc
4+
*$py.class
5+
*~
6+
.coverage
7+
coverage.xml
8+
build/
9+
dist/
10+
.tox/
11+
nosetests.xml
12+
env*/
13+
tmp/
14+
Data.fs*
15+
*.sublime-project
16+
*.sublime-workspace
17+
.*.sw?
18+
.sw?
19+
.DS_Store
20+
coverage
21+
test
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
0.0
2+
---
3+
4+
- Initial version.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
include *.txt *.ini *.cfg *.rst
2+
recursive-include pypi *.ico *.png *.css *.gif *.jpg *.pt *.txt *.mak *.mako *.js *.html *.xml *.jinja2
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
Python Package Index
2+
====================
3+
4+
Getting Started
5+
---------------
6+
7+
- Change directory into your newly created project.
8+
9+
cd pypi
10+
11+
- Create a Python virtual environment.
12+
13+
python3 -m venv env
14+
15+
- Upgrade packaging tools.
16+
17+
env/bin/pip install --upgrade pip setuptools
18+
19+
- Install the project in editable mode with its testing requirements.
20+
21+
env/bin/pip install -e ".[testing]"
22+
23+
- Run your project's tests.
24+
25+
env/bin/pytest
26+
27+
- Run your project.
28+
29+
env/bin/pserve development.ini
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
###
2+
# app configuration
3+
# https://docs.pylonsproject.org/projects/pyramid/en/latest/narr/environment.html
4+
###
5+
6+
[app:main]
7+
use = egg:pypi
8+
9+
pyramid.reload_templates = true
10+
pyramid.debug_authorization = false
11+
pyramid.debug_notfound = false
12+
pyramid.debug_routematch = false
13+
pyramid.default_locale_name = en
14+
pyramid.includes =
15+
pyramid_debugtoolbar
16+
17+
# By default, the toolbar only appears for clients from IP addresses
18+
# '127.0.0.1' and '::1'.
19+
# debugtoolbar.hosts = 127.0.0.1 ::1
20+
21+
###
22+
# wsgi server configuration
23+
###
24+
25+
[server:main]
26+
use = egg:waitress#main
27+
listen = localhost:6543
28+
29+
###
30+
# logging configuration
31+
# https://docs.pylonsproject.org/projects/pyramid/en/latest/narr/logging.html
32+
###
33+
34+
[loggers]
35+
keys = root, pypi
36+
37+
[handlers]
38+
keys = console
39+
40+
[formatters]
41+
keys = generic
42+
43+
[logger_root]
44+
level = INFO
45+
handlers = console
46+
47+
[logger_pypi]
48+
level = DEBUG
49+
handlers =
50+
qualname = pypi
51+
52+
[handler_console]
53+
class = StreamHandler
54+
args = (sys.stderr,)
55+
level = NOTSET
56+
formatter = generic
57+
58+
[formatter_generic]
59+
format = %(asctime)s %(levelname)-5.5s [%(name)s:%(lineno)s][%(threadName)s] %(message)s
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
###
2+
# app configuration
3+
# https://docs.pylonsproject.org/projects/pyramid/en/latest/narr/environment.html
4+
###
5+
6+
[app:main]
7+
use = egg:pypi
8+
9+
pyramid.reload_templates = false
10+
pyramid.debug_authorization = false
11+
pyramid.debug_notfound = false
12+
pyramid.debug_routematch = false
13+
pyramid.default_locale_name = en
14+
15+
###
16+
# wsgi server configuration
17+
###
18+
19+
[server:main]
20+
use = egg:waitress#main
21+
listen = *:6543
22+
23+
###
24+
# logging configuration
25+
# https://docs.pylonsproject.org/projects/pyramid/en/latest/narr/logging.html
26+
###
27+
28+
[loggers]
29+
keys = root, pypi
30+
31+
[handlers]
32+
keys = console
33+
34+
[formatters]
35+
keys = generic
36+
37+
[logger_root]
38+
level = WARN
39+
handlers = console
40+
41+
[logger_pypi]
42+
level = WARN
43+
handlers =
44+
qualname = pypi
45+
46+
[handler_console]
47+
class = StreamHandler
48+
args = (sys.stderr,)
49+
level = NOTSET
50+
formatter = generic
51+
52+
[formatter_generic]
53+
format = %(asctime)s %(levelname)-5.5s [%(name)s:%(lineno)s][%(threadName)s] %(message)s
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
from pyramid.config import Configurator
2+
3+
4+
def main(global_config, **settings):
5+
""" This function returns a Pyramid WSGI application.
6+
"""
7+
config = Configurator(settings=settings)
8+
init_includes(config)
9+
init_routing(config)
10+
11+
return config.make_wsgi_app()
12+
13+
14+
def init_includes(config):
15+
config.include('pyramid_chameleon')
16+
17+
18+
def init_routing(config):
19+
config.add_static_view('static', 'static', cache_max_age=3600)
20+
21+
# home controller
22+
config.add_route('home', '/')
23+
config.add_route('about', '/about')
24+
25+
# package controller
26+
config.add_route('popular', '/{num}', custom_predicates=[
27+
lambda info, _: info['match'].get('num', '').isdigit()
28+
])
29+
30+
config.add_route('package_details', '/project/{package_name}')
31+
config.add_route('package_details/', '/project/{package_name}/')
32+
33+
config.add_route('releases', '/project/{package_name}/releases')
34+
config.add_route('releases/', '/project/{package_name}/releases/')
35+
36+
config.add_route('release_version', '/project/{package_name}/releases/{release_version}')
37+
38+
# account controller
39+
config.add_route('account_home', '/account')
40+
config.add_route('login', '/account/login')
41+
config.add_route('register', '/account/register')
42+
config.add_route('logout', '/account/logout')
43+
44+
# cms controller -- VERY END
45+
config.add_route('cms_page', '*subpath')
46+
47+
config.scan()

src/ch9-sqlalchemy/final/pypi_sqlalchemy/pypi/controllers/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)