summaryrefslogtreecommitdiff
path: root/cherrypy/tutorial
diff options
context:
space:
mode:
authorGustavo Picon <tabo@tabo.pe>2014-01-12 13:57:44 -0500
committerGustavo Picon <tabo@tabo.pe>2014-01-12 13:57:44 -0500
commitc26eb490862e664dc4ef4ea6e55c1dbd106146c4 (patch)
treef997c23aa6d04fc7db78e66ad5f58429b3be824e /cherrypy/tutorial
parentfb84f7713d6ced0031dacb0e7e59d516cc681a4d (diff)
downloadcherrypy-git-c26eb490862e664dc4ef4ea6e55c1dbd106146c4.tar.gz
Running: autopep8 -vvvvv -i `find . -name '*.py'`
--HG-- branch : autopep8
Diffstat (limited to 'cherrypy/tutorial')
-rw-r--r--cherrypy/tutorial/bonus-sqlobject.py55
-rw-r--r--cherrypy/tutorial/tut01_helloworld.py2
-rw-r--r--cherrypy/tutorial/tut02_expose_methods.py1
-rw-r--r--cherrypy/tutorial/tut03_get_and_post.py2
-rw-r--r--cherrypy/tutorial/tut04_complex_site.py5
-rw-r--r--cherrypy/tutorial/tut05_derived_objects.py1
-rw-r--r--cherrypy/tutorial/tut06_default_method.py1
-rw-r--r--cherrypy/tutorial/tut07_sessions.py1
-rw-r--r--cherrypy/tutorial/tut08_generators_and_yield.py1
-rw-r--r--cherrypy/tutorial/tut10_http_errors.py5
10 files changed, 38 insertions, 36 deletions
diff --git a/cherrypy/tutorial/bonus-sqlobject.py b/cherrypy/tutorial/bonus-sqlobject.py
index c43feb45..1d7458f9 100644
--- a/cherrypy/tutorial/bonus-sqlobject.py
+++ b/cherrypy/tutorial/bonus-sqlobject.py
@@ -38,15 +38,18 @@ from sqlobject import *
__connection__ = 'mysql://root:@localhost/test'
# this is our (only) data class.
+
+
class Contact(SQLObject):
- lastName = StringCol(length = 50, notNone = True)
- firstName = StringCol(length = 50, notNone = True)
- phone = StringCol(length = 30, notNone = True, default = '')
- email = StringCol(length = 30, notNone = True, default = '')
- url = StringCol(length = 100, notNone = True, default = '')
+ lastName = StringCol(length=50, notNone=True)
+ firstName = StringCol(length=50, notNone=True)
+ phone = StringCol(length=30, notNone=True, default='')
+ email = StringCol(length=30, notNone=True, default='')
+ url = StringCol(length=100, notNone=True, default='')
class ContactManager:
+
def index(self):
# Let's display a list of all stored contacts.
contacts = Contact.select()
@@ -68,8 +71,7 @@ class ContactManager:
index.exposed = True
-
- def edit(self, id = 0):
+ def edit(self, id=0):
# we really want id as an integer. Since GET/POST parameters
# are always passed as strings, let's convert it.
id = int(id)
@@ -83,7 +85,6 @@ class ContactManager:
contact = None
title = "New Contact"
-
# In the following template code, please note that we use
# Cheetah's $getVar() construct for the form values. We have
# to do this because contact may be set to None (see above).
@@ -105,7 +106,6 @@ class ContactManager:
edit.exposed = True
-
def delete(self, id):
# Delete the specified contact
contact = Contact.get(int(id))
@@ -114,8 +114,7 @@ class ContactManager:
delete.exposed = True
-
- def store(self, lastName, firstName, phone, email, url, id = None):
+ def store(self, lastName, firstName, phone, email, url, id=None):
if id and int(id) > 0:
# If an id was specified, update an existing contact.
contact = Contact.get(int(id))
@@ -124,25 +123,24 @@ class ContactManager:
# cause multiple UPDATE clauses. So we'll just do it all
# in a single pass through the set() method.
contact.set(
- lastName = lastName,
- firstName = firstName,
- phone = phone,
- email = email,
- url = url)
+ lastName=lastName,
+ firstName=firstName,
+ phone=phone,
+ email=email,
+ url=url)
else:
# Otherwise, add a new contact.
contact = Contact(
- lastName = lastName,
- firstName = firstName,
- phone = phone,
- email = email,
- url = url)
+ lastName=lastName,
+ firstName=firstName,
+ phone=phone,
+ email=email,
+ url=url)
return 'Stored. <a href="./">Return to Index</a>'
store.exposed = True
-
def reset(self):
# Drop existing table
Contact.dropTable(True)
@@ -152,17 +150,18 @@ class ContactManager:
# Create some sample data
Contact(
- firstName = 'Hendrik',
- lastName = 'Mans',
- email = 'hendrik@mans.de',
- phone = '++49 89 12345678',
- url = 'http://www.mornography.de')
+ firstName='Hendrik',
+ lastName='Mans',
+ email='hendrik@mans.de',
+ phone='++49 89 12345678',
+ url='http://www.mornography.de')
return "reset completed!"
reset.exposed = True
-print("If you're running this application for the first time, please go to http://localhost:8080/reset once in order to create the database!")
+print(
+ "If you're running this application for the first time, please go to http://localhost:8080/reset once in order to create the database!")
cherrypy.quickstart(ContactManager())
diff --git a/cherrypy/tutorial/tut01_helloworld.py b/cherrypy/tutorial/tut01_helloworld.py
index ef947601..2fa61afa 100644
--- a/cherrypy/tutorial/tut01_helloworld.py
+++ b/cherrypy/tutorial/tut01_helloworld.py
@@ -7,7 +7,9 @@ The most basic (working) CherryPy application possible.
# Import CherryPy global namespace
import cherrypy
+
class HelloWorld:
+
""" Sample request handler class. """
def index(self):
diff --git a/cherrypy/tutorial/tut02_expose_methods.py b/cherrypy/tutorial/tut02_expose_methods.py
index c17e9d29..6c6446eb 100644
--- a/cherrypy/tutorial/tut02_expose_methods.py
+++ b/cherrypy/tutorial/tut02_expose_methods.py
@@ -7,6 +7,7 @@ handler.
import cherrypy
+
class HelloWorld:
def index(self):
diff --git a/cherrypy/tutorial/tut03_get_and_post.py b/cherrypy/tutorial/tut03_get_and_post.py
index 6163b42a..a487a909 100644
--- a/cherrypy/tutorial/tut03_get_and_post.py
+++ b/cherrypy/tutorial/tut03_get_and_post.py
@@ -19,7 +19,7 @@ class WelcomePage:
</form>'''
index.exposed = True
- def greetUser(self, name = None):
+ def greetUser(self, name=None):
# CherryPy passes all GET and POST variables as method parameters.
# It doesn't make a difference where the variables come from, how
# large their contents are, and so on.
diff --git a/cherrypy/tutorial/tut04_complex_site.py b/cherrypy/tutorial/tut04_complex_site.py
index 9ced38dd..d870388e 100644
--- a/cherrypy/tutorial/tut04_complex_site.py
+++ b/cherrypy/tutorial/tut04_complex_site.py
@@ -9,6 +9,7 @@ import cherrypy
class HomePage:
+
def index(self):
return '''
<p>Hi, this is the home page! Check out the other
@@ -22,6 +23,7 @@ class HomePage:
class JokePage:
+
def index(self):
return '''
<p>"In Python, how do you create a string of random
@@ -31,6 +33,7 @@ class JokePage:
class LinksPage:
+
def __init__(self):
# Request handler objects can create their own nested request
# handler objects. Simply create them inside their __init__
@@ -59,6 +62,7 @@ class LinksPage:
class ExtraLinksPage:
+
def index(self):
# Note the relative link back to the Links page!
return '''
@@ -95,4 +99,3 @@ if __name__ == '__main__':
else:
# This branch is for the test suite; you can ignore it.
cherrypy.tree.mount(root, config=tutconf)
-
diff --git a/cherrypy/tutorial/tut05_derived_objects.py b/cherrypy/tutorial/tut05_derived_objects.py
index 2649bc6d..9f4f2c32 100644
--- a/cherrypy/tutorial/tut05_derived_objects.py
+++ b/cherrypy/tutorial/tut05_derived_objects.py
@@ -80,4 +80,3 @@ if __name__ == '__main__':
else:
# This branch is for the test suite; you can ignore it.
cherrypy.tree.mount(HomePage(), config=tutconf)
-
diff --git a/cherrypy/tutorial/tut06_default_method.py b/cherrypy/tutorial/tut06_default_method.py
index 3a4bd8ef..f71c315a 100644
--- a/cherrypy/tutorial/tut06_default_method.py
+++ b/cherrypy/tutorial/tut06_default_method.py
@@ -61,4 +61,3 @@ if __name__ == '__main__':
else:
# This branch is for the test suite; you can ignore it.
cherrypy.tree.mount(UsersPage(), config=tutconf)
-
diff --git a/cherrypy/tutorial/tut07_sessions.py b/cherrypy/tutorial/tut07_sessions.py
index 26c3658b..62efa440 100644
--- a/cherrypy/tutorial/tut07_sessions.py
+++ b/cherrypy/tutorial/tut07_sessions.py
@@ -41,4 +41,3 @@ if __name__ == '__main__':
else:
# This branch is for the test suite; you can ignore it.
cherrypy.tree.mount(HitCounter(), config=tutconf)
-
diff --git a/cherrypy/tutorial/tut08_generators_and_yield.py b/cherrypy/tutorial/tut08_generators_and_yield.py
index 2b33a9a7..40566e32 100644
--- a/cherrypy/tutorial/tut08_generators_and_yield.py
+++ b/cherrypy/tutorial/tut08_generators_and_yield.py
@@ -44,4 +44,3 @@ if __name__ == '__main__':
else:
# This branch is for the test suite; you can ignore it.
cherrypy.tree.mount(GeneratorDemo(), config=tutconf)
-
diff --git a/cherrypy/tutorial/tut10_http_errors.py b/cherrypy/tutorial/tut10_http_errors.py
index d8352e38..a18777ef 100644
--- a/cherrypy/tutorial/tut10_http_errors.py
+++ b/cherrypy/tutorial/tut10_http_errors.py
@@ -18,7 +18,8 @@ import cherrypy
class HTTPErrorDemo(object):
# Set a custom response for 403 errors.
- _cp_config = {'error_page.403' : os.path.join(curpath, "custom_error.html")}
+ _cp_config = {'error_page.403':
+ os.path.join(curpath, "custom_error.html")}
def index(self):
# display some links that will result in errors
@@ -57,7 +58,7 @@ class HTTPErrorDemo(object):
def error(self, code):
# raise an error based on the get query
- raise cherrypy.HTTPError(status = code)
+ raise cherrypy.HTTPError(status=code)
error.exposed = True
def messageArg(self):