diff options
| author | ianb <devnull@localhost> | 2005-08-22 18:22:27 +0000 |
|---|---|---|
| committer | ianb <devnull@localhost> | 2005-08-22 18:22:27 +0000 |
| commit | 27f2c911e823216a8db5873a53b1da10c0a4c4d1 (patch) | |
| tree | 1ed476b090fdda9834d088b38c54c27687e8e23b /examples/todo_sql | |
| parent | e17ed7b172e6b8e914c28cd3dfec53fa7b452eb7 (diff) | |
| download | paste-27f2c911e823216a8db5873a53b1da10c0a4c4d1.tar.gz | |
Examples will be kept in a separate location in the repository in the future; build-pkg is deprecated also
Diffstat (limited to 'examples/todo_sql')
| -rw-r--r-- | examples/todo_sql/__init__.py | 6 | ||||
| -rw-r--r-- | examples/todo_sql/db.py | 12 | ||||
| -rw-r--r-- | examples/todo_sql/server.conf | 25 | ||||
| -rw-r--r-- | examples/todo_sql/sitepage.py | 35 | ||||
| -rw-r--r-- | examples/todo_sql/templates/generic_error.pt | 7 | ||||
| -rw-r--r-- | examples/todo_sql/templates/index.pt | 22 | ||||
| -rw-r--r-- | examples/todo_sql/templates/standard_template.pt | 43 | ||||
| -rw-r--r-- | examples/todo_sql/templates/view_list.pt | 57 | ||||
| -rw-r--r-- | examples/todo_sql/web/__init__.py | 17 | ||||
| -rw-r--r-- | examples/todo_sql/web/edit_list.py | 29 | ||||
| -rw-r--r-- | examples/todo_sql/web/index.py | 7 | ||||
| -rw-r--r-- | examples/todo_sql/web/static/stylesheet.css | 13 | ||||
| -rw-r--r-- | examples/todo_sql/web/view_list.py | 48 |
13 files changed, 0 insertions, 321 deletions
diff --git a/examples/todo_sql/__init__.py b/examples/todo_sql/__init__.py deleted file mode 100644 index 3415d9d..0000000 --- a/examples/todo_sql/__init__.py +++ /dev/null @@ -1,6 +0,0 @@ -from paste.util.thirdparty import add_package - -add_package('ZopePageTemplates') -add_package('Component') -add_package('ZPTKit') -add_package('sqlobject') diff --git a/examples/todo_sql/db.py b/examples/todo_sql/db.py deleted file mode 100644 index 21f36fb..0000000 --- a/examples/todo_sql/db.py +++ /dev/null @@ -1,12 +0,0 @@ -from sqlobject import * - -class TodoList(SQLObject): - - description = StringCol(notNull=True) - items = MultipleJoin('TodoItem') - -class TodoItem(SQLObject): - - todo_list = ForeignKey('TodoList') - description = StringCol(notNull=True) - done = BoolCol(notNull=True, default=False) diff --git a/examples/todo_sql/server.conf b/examples/todo_sql/server.conf deleted file mode 100644 index 4595407..0000000 --- a/examples/todo_sql/server.conf +++ /dev/null @@ -1,25 +0,0 @@ -# -*- python -*- Note: this file is in Python syntax - -import os -database = 'sqlite:%s/data.db' % os.path.dirname(__file__) - -app_template = 'webkit_zpt' -framework = 'webkit' -app_name = 'todo_sql' -publish_dir = os.path.join(os.path.dirname(__file__), 'web') - -## Server options: - -verbose = True -# The name of the server-type to start: -server = 'wsgiutils' -# If true, files will be regularly polled and the server restarted -# if files are modified: -reload = True -# If true, tracebacks will be shown in the browser: -debug = True - -#use_package('sqlobject') -#use_package('ZPTKit') -#use_package('wsgi-utils') - diff --git a/examples/todo_sql/sitepage.py b/examples/todo_sql/sitepage.py deleted file mode 100644 index 9c88685..0000000 --- a/examples/todo_sql/sitepage.py +++ /dev/null @@ -1,35 +0,0 @@ -import os -from Component import CPage -from Component.notify import NotifyComponent -from ZPTKit import ZPTComponent -from todo_sql.db import * - -class SitePage(CPage): - - components = [ - ZPTComponent([os.path.join(os.path.dirname(__file__), - 'templates')]), - NotifyComponent()] - - def title(self): - return self.options.get('title', CPage.title(self)) - - def awake(self, trans): - CPage.awake(self, trans) - self.baseURL = self.request().environ()['todo_sql.base_url'] - self.baseStaticURL = self.baseURL + '/static' - self.options.lists = list(TodoList.select()) - self.setup() - - def setup(self): - pass - - def sleep(self, trans): - self.teardown() - CPage.sleep(self, trans) - - def teardown(self): - pass - - def writeHTML(self): - self.writeTemplate() diff --git a/examples/todo_sql/templates/generic_error.pt b/examples/todo_sql/templates/generic_error.pt deleted file mode 100644 index 7b32820..0000000 --- a/examples/todo_sql/templates/generic_error.pt +++ /dev/null @@ -1,7 +0,0 @@ -<html metal:use-macro="here/standard_template.pt/macros/page"> -<metal:body fill-slot="body"> - -<tal:block replace="structure options/error_message" /> - -</metal:body> -</html>
\ No newline at end of file diff --git a/examples/todo_sql/templates/index.pt b/examples/todo_sql/templates/index.pt deleted file mode 100644 index b889e14..0000000 --- a/examples/todo_sql/templates/index.pt +++ /dev/null @@ -1,22 +0,0 @@ -<html metal:use-macro="here/standard_template.pt/macros/page"> -<metal:body fill-slot="body"> - -<ul> - <li tal:repeat="list options/lists"> - <a tal:attributes="href python: '%s/view_list?id=%s' % (servlet.baseURL, list.id)" - tal:content="list/description">list</a></li> -</ul> - -<p tal:condition="not: options/lists"> - There are no lists to display -</p> - -<form action="./edit_list" method="POST"> - Create a new list:<br> - <input type="hidden" name="id" value="new"> - <input type="hidden" name="_action_" value="save"> - <input type="text" name="description"> - <input type="submit" value="Create!!!!"> -</form> -</metal:body> -</html> diff --git a/examples/todo_sql/templates/standard_template.pt b/examples/todo_sql/templates/standard_template.pt deleted file mode 100644 index e3ff01d..0000000 --- a/examples/todo_sql/templates/standard_template.pt +++ /dev/null @@ -1,43 +0,0 @@ -<metal:tpl define-macro="page"> -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" - "http://www.w3.org/TR/REC-html40/loose.dtd"> -<html lang="en-US"> -<head> -<title tal:content="servlet/title">title</title> -<link rel="stylesheet" type="text/css" - tal:attributes="href python: servlet.baseStaticURL + '/stylesheet.css'"> - -<metal:slot define-slot="extra_head"></metal:slot> - -</head> -<body> - -<h1 id="header"><tal:mark replace="servlet/title"/></h1> - -<table width="100%"> -<tr> -<td id="sidenav" width="20%"> -<a tal:attributes="href servlet/baseURL">Home</a><br> -<tal:for repeat="list options/lists"> - <a tal:attributes="href python: '%s/view_list?id=%s' % - (servlet.baseURL, list.id)" - tal:content="list/description">link</a><br> -</tal:for> -</td> - -<td> -<span tal:replace="structure servlet/messageText"> -This is where the notification messages go. -</span> - -<div id="content"> -<metal:tpl define-slot="body"> -[This page has not customized its "body" slot] -</metal:tpl> -</div> - -</td></tr></table> - -</body> -</html> -</metal:tpl> diff --git a/examples/todo_sql/templates/view_list.pt b/examples/todo_sql/templates/view_list.pt deleted file mode 100644 index 2a85b13..0000000 --- a/examples/todo_sql/templates/view_list.pt +++ /dev/null @@ -1,57 +0,0 @@ -<html metal:use-macro="here/standard_template.pt/macros/page"> -<metal:body fill-slot="body"> - -<form action="view_list?_action_=check" method="POST"> -<input type="hidden" name="id" - tal:attributes="value options/list/id"> - -<table> -<tr> - <th>Done?</th> - <th>Description</th> -</tr> - -<tr tal:repeat="item options/list_items"> - <tal:let define="name python: 'item_%s' % item.id"> - <td> - <input type="checkbox" - tal:attributes="name name; - id name; - checked item/done"> - </td> - <td> - <label tal:attributes="for name" - tal:content="item/description">description</label> - </td> - <td><a tal:attributes=" - href python: 'view_list?_action_=destroy&item_id=%s' - % item.id">[delete]</a></td> - </tal:let> -</tr> - -<tr tal:condition="not: options/list_items"> - <td colspan=2>No items to display</td> -</tr> - -</table> - -<input type="submit" value="Update item status"> -</form> - -<form action="view_list?_action_=add" method="POST"> -<input type="hidden" name="id" - tal:attributes="value options/list/id"> -Add item:<br> -<input type="text" style="width: 100%" name="description"><br> -<input type="submit" value="Add"> -</form> - -<form action="edit_list?_action_=destroy" method="POST"> -<input type="hidden" name="id" - tal:attributes="value options/list/id"> -<input type="submit" value="Delete this list" - onclick="return window.confirm('Really delete this list?')"> -</form> - -</metal:body> -</html> diff --git a/examples/todo_sql/web/__init__.py b/examples/todo_sql/web/__init__.py deleted file mode 100644 index ed4edc7..0000000 --- a/examples/todo_sql/web/__init__.py +++ /dev/null @@ -1,17 +0,0 @@ -import os -from paste import wsgilib -from paste.util.thirdparty import add_package -add_package('sqlobject') -import sqlobject - -sql_set = False - -def urlparser_hook(environ): - global sql_set - if not environ.has_key('todo_sql.base_url'): - environ['todo_sql.base_url'] = environ['SCRIPT_NAME'] - if not sql_set: - sql_set = True - db_uri = environ['paste.config']['database'] - sqlobject.sqlhub.processConnection = sqlobject.connectionForURI( - db_uri) diff --git a/examples/todo_sql/web/edit_list.py b/examples/todo_sql/web/edit_list.py deleted file mode 100644 index 0bd3372..0000000 --- a/examples/todo_sql/web/edit_list.py +++ /dev/null @@ -1,29 +0,0 @@ -from todo_sql.sitepage import SitePage -from todo_sql.db import * - -class edit_list(SitePage): - - def setup(self): - self.list_id = self.request().field('id') - if self.list_id != 'new': - self.list = TodoList.get(int(self.list_id)) - self.options.title = 'Edit list ' - - def actions(self): - return ['save', 'destroy'] - - def save(self): - desc = self.request().field('description') - if self.list_id == 'new': - self.list = TodoList(description=desc) - self.message('List created') - else: - self.list.description = desc - self.message('List updated') - self.sendRedirectAndEnd('./view_list?id=%s' % self.list.id) - - def destroy(self): - desc = self.list.description - self.list.destroySelf() - self.message('List %s deleted' % desc) - self.sendRedirectAndEnd('./') diff --git a/examples/todo_sql/web/index.py b/examples/todo_sql/web/index.py deleted file mode 100644 index 55b1f98..0000000 --- a/examples/todo_sql/web/index.py +++ /dev/null @@ -1,7 +0,0 @@ -from todo_sql.sitepage import SitePage -from todo_sql.db import * - -class index(SitePage): - - def setup(self): - self.options.title = 'List of Lists' diff --git a/examples/todo_sql/web/static/stylesheet.css b/examples/todo_sql/web/static/stylesheet.css deleted file mode 100644 index d70e9ec..0000000 --- a/examples/todo_sql/web/static/stylesheet.css +++ /dev/null @@ -1,13 +0,0 @@ -body { - font-family: Helvetica, Arial, sans-serif; -} - -pre { - overflow: auto; -} - -div.notifyMessage { - border: 2px solid black; - background-color: #007700; - color: #ffffff; -} diff --git a/examples/todo_sql/web/view_list.py b/examples/todo_sql/web/view_list.py deleted file mode 100644 index a7105d6..0000000 --- a/examples/todo_sql/web/view_list.py +++ /dev/null @@ -1,48 +0,0 @@ -from todo_sql.sitepage import SitePage -from todo_sql.db import * - -class view_list(SitePage): - - def setup(self): - self.options.list = TodoList.get(int(self.request().field('id'))) - self.options.list_items = list(self.options.list.items) - self.options.title = 'List: %s' % self.options.list.description - - def actions(self): - return ['check', 'add', 'destroy'] - - def check(self): - field = self.request().field - for item in self.options.list.items: - checked = field('item_%s' % item.id, False) - if not checked and item.done: - self.message('Item %s marked not done' - % item.description) - item.done = False - if checked and not item.done: - self.message('Item %s marked done' - % item.description) - item.done = True - self.sendRedirectAndEnd( - './view_list?id=%s' % self.options.list.id) - - def add(self): - desc = self.request().field('description') - if not desc: - self.message('You must give a description') - else: - TodoItem(todo_list=self.options.list, - description=desc) - self.message('Item added') - self.sendRedirectAndEnd( - './view_list?id=%s' % self.options.list.id) - - def destroy(self): - id = int(self.request.field('item_id')) - item = TodoItem.get(id) - assert item.todo_list.id == self.options.list.id - desc = description - item.destroySelf() - self.message("Item %s removed" % desc) - self.sendRedirectAndEnd( - './view_list?id=%s' % self.options.list.id) |
