From 4431828c677e6104b7abc62b31a933d2793ff6cf Mon Sep 17 00:00:00 2001
From: ianb
Date: Fri, 22 Apr 2005 02:44:48 +0000
Subject: Renamed WSGIKit to Paste
---
examples/todo/QUICKSTART | 55 +++++++++++
examples/todo/ROADMAP | 35 +++++++
examples/todo/SitePage.py | 67 +++++++++++++
examples/todo/__init__.py | 17 ++++
examples/todo/api.py | 2 +
examples/todo/check.png | Bin 0 -> 2248 bytes
examples/todo/favicon.ico | 191 ++++++++++++++++++++++++++++++++++++++
examples/todo/index.py | 47 ++++++++++
examples/todo/list.py | 24 +++++
examples/todo/lists.py | 98 +++++++++++++++++++
examples/todo/login.py | 51 ++++++++++
examples/todo/logout.py | 10 ++
examples/todo/main.css | 50 ++++++++++
examples/todo/model.py | 92 ++++++++++++++++++
examples/todo/register.py | 28 ++++++
examples/todo/tests/test_model.py | 71 ++++++++++++++
16 files changed, 838 insertions(+)
create mode 100644 examples/todo/QUICKSTART
create mode 100644 examples/todo/ROADMAP
create mode 100644 examples/todo/SitePage.py
create mode 100644 examples/todo/__init__.py
create mode 100644 examples/todo/api.py
create mode 100644 examples/todo/check.png
create mode 100644 examples/todo/favicon.ico
create mode 100644 examples/todo/index.py
create mode 100644 examples/todo/list.py
create mode 100644 examples/todo/lists.py
create mode 100644 examples/todo/login.py
create mode 100644 examples/todo/logout.py
create mode 100644 examples/todo/main.css
create mode 100644 examples/todo/model.py
create mode 100644 examples/todo/register.py
create mode 100644 examples/todo/tests/test_model.py
(limited to 'examples/todo')
diff --git a/examples/todo/QUICKSTART b/examples/todo/QUICKSTART
new file mode 100644
index 0000000..1de319e
--- /dev/null
+++ b/examples/todo/QUICKSTART
@@ -0,0 +1,55 @@
+WSGIKit Example Application: todo
+=================================
+
+This is a simple application intended to demonstrate the basic usage of
+a WSGIKit site as well as some WSGI features such as a middleware hooks
+that performs URL rewriting.
+
+ROADMAP lists some of the features we intend to implement in the future.
+
+Installing WSGIKit
+------------------
+
+`docs/WSGIKit.txt`__ describes a basic user-level installation of
+WSGIKit and supported WSGI servers.
+
+.. __: http://svn.w4py.org/WSGIKit/trunk/docs/WSGIKit.txt
+
+Your First Run
+--------------
+
+The commands::
+
+ cd WSGIKit/trunk
+ wsgikit/server.py --server=wsgiutils --webkit-dir=example/todo \
+ --port 8080 -D --data-dir='/var/www/data1'
+
+If you do not have $PYTHONPATH set up as described WSGIKit.txt then you
+can add a like such as this::
+
+ env PYTHONPATH=`pwd` wsgikit/server.py ...
+
+Replace 'env' with 'setenv' if you're using csh or tcsh.
+
+Then open up http://localhost:8080/
+
+Running Multiple Instances
+--------------------------
+
+Any options not defined in server.py are passed on to the application.
+In the previous example --data-dir is an optional argument that
+specifies where to put the todo list, which is a pickled instance of the
+Manager class in model.py.
+
+Simply specify an alternate --port and --data-dir to run multiple
+instances simultaneously. The todo lists are saved to disk after each
+modification to user accounts or lists and saved as state.pickle.
+
+Testing
+-------
+
+There is a simple set of tests in examples/todo/tests that you can run
+using py.test (see `PyPy doc`__ for information on how to set up py.test).
+The tests only cover the logic contained in todo/model.py
+
+.. __: http://codespeak.net/pypy/index.cgi?doc/howtopypy.html
diff --git a/examples/todo/ROADMAP b/examples/todo/ROADMAP
new file mode 100644
index 0000000..ef2350e
--- /dev/null
+++ b/examples/todo/ROADMAP
@@ -0,0 +1,35 @@
+=======
+ROADMAP
+=======
+
+Items to do
+===========
+
+- add checkboxes for done/not-done states
+
+- by default, only show not-done items (with a toggle between done/not-done)
+
+- give a link/page to see the completed items
+
+- show the number of items (visually or textually) in a todo list
+
+- move items from one list to another
+
+- "share" a list, i.e. a read-only version for an unauthenticated? user
+
+- email a list
+
+- see multiple lists at once
+
+- "subscribe" to a list for status changes or reminders
+
+- add due date, completion date and creation date to todo items
+
+- nest-able todo lists? (a todo list could be contained in another?)
+
+Bugs to fix
+===========
+
+- list names don't work with spaces in them... let's make it so they can
+
+- ///delete doesn't work (can't delete/obliterate a list)
diff --git a/examples/todo/SitePage.py b/examples/todo/SitePage.py
new file mode 100644
index 0000000..178e471
--- /dev/null
+++ b/examples/todo/SitePage.py
@@ -0,0 +1,67 @@
+
+import os
+from wsgikit.webkit.wkservlet import Page
+import api
+
+
+class SitePage(Page):
+
+ manager = None
+
+ def awake(self, trans):
+ super(SitePage, self).awake(trans)
+ if not getattr(self, 'manager', None):
+ datadir = trans.request().environ().get('wsgikit.config',{}).get('datadir','.')
+ self.manager = api.Manager.load(root=datadir)
+ self.baseURL = trans.request().environ()['todo.base_url']
+ self.username = self.session().value('username', None)
+ if not self.username and self.loginRequired():
+ self.transaction().forward('/login')
+
+ def loginRequired(self):
+ return True
+
+ def sleep(self, trans):
+ super(SitePage, self).sleep(trans)
+ if self.manager:
+ self.manager.save()
+
+ def preAction(self, actionName):
+ pass
+
+ def postAction(self, actionName):
+ pass
+
+ def writeStyleSheet(self):
+ self.write("""\n""")
+ self.write("""\n""" % self.baseURL)
+
+ def writeDocType(self):
+ self.write("""
+ \n""")
+
+ def title(self):
+ return "WSGIKit ToDo list test"
+
+ def htBodyArgs(self):
+ return ""
+
+ def writeBodyParts(self):
+ self.writePreContent()
+ self.writeContent()
+ self.writePostContent()
+
+ def writePreContent(self):
+ self.write("""
Webware for Python is a suite of software components for developing object-oriented, web-based applications. The suite uses well known design patterns and includes popular features such as a fast application server, Python Server Pages (PSP), and a CGI wrapper.
Component version 0.1 released. Component provides a subclass of
+WebKit.Page that makes it easier to reuse code from multiple
+sources that extend the capability of servlets.
Webware has switched its source-code repository from using Sourceforge's
+CVS service to using a Subversion hosted on the webwareforpython.org
+(aka w4py.org) server. Here are some instructions on how to access the repository.
+Newcomers to subversion may be interested in the Subversion book.
You can now find the WSGI-enabled Webware implementation at
+svn://colorstudy.com/trunk/WSGIKit or view online.
+It is now distutil-installable and includes documentation.
An effort is in the works to port Webware to the new
+Web Server Gateway Interface (WSGI). The WSGI is an effort by
+the Python Web-SIG to create a standard
+interface for Python web applications, frameworks, and servers, and
+should allow Webware to be run in different environments, and alongside
+other Python web frameworks. Work can be found in a Subversion repository
+at http://svn.w4py.org/WSGIKit/trunk and viewed online.
Thanks to Eric Radman for the new site design, and Jacob Hanson for the logo.
+We're in the process of moving content over from the old site,
+re-organizing, and updating it where necessary. Please bear with us.
The Webware project has been generously provided with a virtual server and
+hosting package, and has registered webwareforpython.org. We will be moving the
+Wiki to this server and are in the process of redesigning the entire website in
+order to provide more useful and better-organized information -- stay tuned!
setCookie method in HTTPResponse. New method supports
+setting the expire time, path (which defaults to "/") and security flag.
+The expire time can be set with constants "ONCLOSE", "NOW", or "NEVER"; or
+you can give an integer timestamp, tuple of integers (as used in the time
+module), or string identifier (like "+1w" for 1 week in the future).
+
Added an experimentalHTTPAdapter.py which serves directly as an
+HTTP server.
+
Added an optional AutoReload setting to enable reloading the server
+whenever source files, including servlets and PSP files are changed.
+
Fix so PSP works with python 2.3a1.
+
Includes an Apache 2 mod_webkit adapter, and pre-compiled DLL for windows.
+
Fixed a problem where escapes in PSP source were not being processed correctly.
+
Restored 0.7 behavior of Page.writeDocType() to output 4.01 Transitional.
+See the 0.8 release notes for more info.