# HG changeset patch # User cmlenz # Date 1236615322 0 # Node ID 502e8cdd722cc7b48b71c9e10614d032482dbe20 # Parent bd1bed216344e801838b06ab753edb7b95124d13 Remove the outdated and unmaintained !TurboGears example. diff --git a/examples/turbogears/README.txt b/examples/turbogears/README.txt deleted file mode 100644 --- a/examples/turbogears/README.txt +++ /dev/null @@ -1,4 +0,0 @@ -GenshiTest - -This is a TurboGears (http://www.turbogears.org) project. It can be -started by running the start-markuptest.py script. diff --git a/examples/turbogears/dev.cfg b/examples/turbogears/dev.cfg deleted file mode 100644 --- a/examples/turbogears/dev.cfg +++ /dev/null @@ -1,63 +0,0 @@ -[global] -# This is where all of your settings go for your development environment -# Settings that are the same for both development and production -# (such as template engine, encodings, etc.) all go in -# genshitest/config/app.cfg - -# DATABASE - -# pick the form for your database -# sqlobject.dburi="postgres://username@hostname/databasename" -# sqlobject.dburi="mysql://username:password@hostname:port/databasename" -# sqlobject.dburi="sqlite:///file_name_and_path" - -# If you have sqlite, here's a simple default to get you started -# in development -sqlobject.dburi="sqlite://%(current_dir_uri)s/devdata.sqlite" - - -# if you are using a database or table type without transactions -# (MySQL default, for example), you should turn off transactions -# by prepending notrans_ on the uri -# sqlobject.dburi="notrans_mysql://username:password@hostname:port/databasename" - -# for Windows users, sqlite URIs look like: -# sqlobject.dburi="sqlite:///drive_letter:/path/to/file" - -# SERVER - -# Some server parameters that you may want to tweak -# server.socket_port=8080 - -# Enable the debug output at the end on pages. -# log_debug_info_filter.on = False - -server.environment="development" -autoreload.package="genshitest" - -# Set to True if you'd like to abort execution if a controller gets an -# unexpected parameter. False by default -tg.strict_parameters = True - -# LOGGING -# Logging configuration generally follows the style of the standard -# Python logging module configuration. Note that when specifying -# log format messages, you need to use *() for formatting variables. -# Deployment independent log configuration is in genshitest/config/log.cfg -[logging] - -[[loggers]] -[[[geshnitest]]] -level='DEBUG' -qualname='genshitest' -handlers=['debug_out'] - -[[[allinfo]]] -level='INFO' -handlers=['debug_out'] - -[[[access]]] -level='INFO' -qualname='turbogears.access' -handlers=['access_out'] -propagate=0 diff --git a/examples/turbogears/genshitest/__init__.py b/examples/turbogears/genshitest/__init__.py deleted file mode 100644 diff --git a/examples/turbogears/genshitest/config/__init__.py b/examples/turbogears/genshitest/config/__init__.py deleted file mode 100644 diff --git a/examples/turbogears/genshitest/config/app.cfg b/examples/turbogears/genshitest/config/app.cfg deleted file mode 100644 --- a/examples/turbogears/genshitest/config/app.cfg +++ /dev/null @@ -1,121 +0,0 @@ -[global] -# The settings in this file should not vary depending on the deployment -# environment. dev.cfg and prod.cfg are the locations for -# the different deployment settings. Settings in this file will -# be overridden by settings in those other files. - -# The commented out values below are the defaults - -# VIEW - -# which view (template engine) to use if one is not specified in the -# template name -tg.defaultview = "genshi" - -# The following kid settings determine the settings used by the kid serializer. - -# One of (html|xml|json) -# kid.outputformat="html" - -# kid.encoding="utf-8" - -# The sitetemplate is used for overall styling of a site that -# includes multiple TurboGears applications -# tg.sitetemplate="" - -# Allow every exposed function to be called as json, -# tg.allow_json = False - -# List of Widgets to include on every page. -# for exemple ['turbogears.mochikit'] -# tg.include_widgets = [] - -# Set to True if the scheduler should be started -# tg.scheduler = False - -# VISIT TRACKING -# Each visit to your application will be assigned a unique visit ID tracked via -# a cookie sent to the visitor's browser. -# -------------- - -# Enable Visit tracking -visit.on=True - -# Number of minutes a visit may be idle before it expires. -# visit.timeout=20 - -# The name of the cookie to transmit to the visitor's browser. -# visit.cookie.name="tg-visit" - -# Domain name to specify when setting the cookie (must begin with . according to -# RFC 2109). The default (None) should work for most cases and will default to -# the machine to which the request was made. NOTE: localhost is NEVER a valid -# value and will NOT WORK. -# visit.cookie.domain=None - -# Specific path for the cookie -# visit.cookie.path="/" - -# The name of the VisitManager plugin to use for visitor tracking. -visit.manager="sqlobject" - -# Database class to use for visit tracking -visit.soprovider.model = "genshitest.model.Visit" - -# IDENTITY -# General configuration of the TurboGears Identity management module -# -------- - -# Switch to turn on or off the Identity management module -identity.on=True - -# [REQUIRED] URL to which CherryPy will internally redirect when an access -# control check fails. If Identity management is turned on, a value for this -# option must be specified. -identity.failure_url="/login" - -# identity.provider='sqlobject' - -# The names of the fields on the login form containing the visitor's user ID -# and password. In addition, the submit button is specified simply so its -# existence may be stripped out prior to passing the form data to the target -# controller. -# identity.form.user_name="user_name" -# identity.form.password="password" -# identity.form.submit="login" - -# What sources should the identity provider consider when determining the -# identity associated with a request? Comma separated list of identity sources. -# Valid sources: form, visit, http_auth -# identity.source="form,http_auth,visit" - -# SqlObjectIdentityProvider -# Configuration options for the default IdentityProvider -# ------------------------- - -# The classes you wish to use for your Identity model. Remember to not use reserved -# SQL keywords for class names (at least unless you specify a different table -# name using sqlmeta). -identity.soprovider.model.user="genshitest.model.User" -identity.soprovider.model.group="genshitest.model.Group" -identity.soprovider.model.permission="genshitest.model.Permission" - -# The password encryption algorithm used when comparing passwords against what's -# stored in the database. Valid values are 'md5' or 'sha1'. If you do not -# specify an encryption algorithm, passwords are expected to be clear text. -# -# The SqlObjectProvider *will* encrypt passwords supplied as part of your login -# form. If you set the password through the password property, like: -# my_user.password = 'secret' -# the password will be encrypted in the database, provided identity is up and -# running, or you have loaded the configuration specifying what encryption to -# use (in situations where identity may not yet be running, like tests). - -# identity.soprovider.encryption_algorithm=None -[/static] -static_filter.on = True -static_filter.dir = "%(top_level_dir)s/static" - -[/favicon.ico] -static_filter.on = True -static_filter.file = "%(top_level_dir)s/static/images/favicon.ico" diff --git a/examples/turbogears/genshitest/config/log.cfg b/examples/turbogears/genshitest/config/log.cfg deleted file mode 100644 --- a/examples/turbogears/genshitest/config/log.cfg +++ /dev/null @@ -1,29 +0,0 @@ -# LOGGING -# Logging is often deployment specific, but some handlers and -# formatters can be defined here. - -[logging] -[[formatters]] -[[[message_only]]] -format='*(message)s' - -[[[full_content]]] -format='*(asctime)s *(name)s *(levelname)s *(message)s' - -[[handlers]] -[[[debug_out]]] -class='StreamHandler' -level='DEBUG' -args='(sys.stdout,)' -formatter='full_content' - -[[[access_out]]] -class='StreamHandler' -level='INFO' -args='(sys.stdout,)' -formatter='message_only' - -[[[error_out]]] -class='StreamHandler' -level='ERROR' -args='(sys.stdout,)' diff --git a/examples/turbogears/genshitest/controllers.py b/examples/turbogears/genshitest/controllers.py deleted file mode 100644 --- a/examples/turbogears/genshitest/controllers.py +++ /dev/null @@ -1,57 +0,0 @@ -import logging - -import cherrypy - -import turbogears -from turbogears import controllers, expose, validate, redirect, widgets -from turbogears import identity - -from genshitest import json - -log = logging.getLogger("genshitest.controllers") - -class Root(controllers.RootController): - - @expose(template="genshitest.templates.welcome") - def index(self): - import time - log.debug("Happy TurboGears Controller Responding For Duty") - return dict(now=time.ctime(), - widget=widgets.TextArea(name="widget_test", - default="Lorem ipsum", - rows=5, cols=40)) - - @expose(template="genshi-text:genshitest.templates.plain", - content_type='text/plain; charset=utf-8') - def plain(self): - return dict(name='world') - - @expose(template="genshitest.templates.login") - def login(self, forward_url=None, previous_url=None, *args, **kw): - - if not identity.current.anonymous \ - and identity.was_login_attempted() \ - and not identity.get_identity_errors(): - raise redirect(forward_url) - - forward_url=None - previous_url= cherrypy.request.path - - if identity.was_login_attempted(): - msg=_("The credentials you supplied were not correct or " - "did not grant access to this resource.") - elif identity.get_identity_errors(): - msg=_("You must provide your credentials before accessing " - "this resource.") - else: - msg=_("Please log in.") - forward_url= cherrypy.request.headers.get("Referer", "/") - cherrypy.response.status=403 - return dict(message=msg, previous_url=previous_url, logging_in=True, - original_parameters=cherrypy.request.params, - forward_url=forward_url) - - @expose() - def logout(self): - identity.current.logout() - raise redirect("/") diff --git a/examples/turbogears/genshitest/json.py b/examples/turbogears/genshitest/json.py deleted file mode 100644 --- a/examples/turbogears/genshitest/json.py +++ /dev/null @@ -1,13 +0,0 @@ -# This module provides helper functions for the JSON part of your -# view, if you are providing a JSON-based API for your app. - -# Here's what most rules would look like: -# @jsonify.when("isinstance(obj, YourClass)") -# def jsonify_yourclass(obj): -# return [obj.val1, obj.val2] -# -# The goal is to break your objects down into simple values: -# lists, dicts, numbers and strings - -from turbojson.jsonify import jsonify - diff --git a/examples/turbogears/genshitest/model.py b/examples/turbogears/genshitest/model.py deleted file mode 100644 --- a/examples/turbogears/genshitest/model.py +++ /dev/null @@ -1,109 +0,0 @@ -from datetime import datetime - -from sqlobject import * - -from turbogears import identity -from turbogears.database import PackageHub - -hub = PackageHub("genshitest") -__connection__ = hub - -# class YourDataClass(SQLObject): -# pass - -class Visit(SQLObject): - class sqlmeta: - table="visit" - - visit_key= StringCol( length=40, alternateID=True, - alternateMethodName="by_visit_key" ) - created= DateTimeCol( default=datetime.now ) - expiry= DateTimeCol() - - def lookup_visit( cls, visit_key ): - try: - return cls.by_visit_key( visit_key ) - except SQLObjectNotFound: - return None - lookup_visit= classmethod(lookup_visit) - -class VisitIdentity(SQLObject): - visit_key = StringCol(length=40, alternateID=True, - alternateMethodName="by_visit_key") - user_id = IntCol() - - -class Group(SQLObject): - """ - An ultra-simple group definition. - """ - - # names like "Group", "Order" and "User" are reserved words in SQL - # so we set the name to something safe for SQL - class sqlmeta: - table="tg_group" - - group_name = UnicodeCol(length=16, alternateID=True, - alternateMethodName="by_group_name") - display_name = UnicodeCol(length=255) - created = DateTimeCol(default=datetime.now) - - # collection of all users belonging to this group - users = RelatedJoin("User", intermediateTable="user_group", - joinColumn="group_id", otherColumn="user_id") - - # collection of all permissions for this group - permissions = RelatedJoin("Permission", joinColumn="group_id", - intermediateTable="group_permission", - otherColumn="permission_id") - - -class User(SQLObject): - """ - Reasonably basic User definition. Probably would want additional attributes. - """ - # names like "Group", "Order" and "User" are reserved words in SQL - # so we set the name to something safe for SQL - class sqlmeta: - table="tg_user" - - user_name = UnicodeCol(length=16, alternateID=True, - alternateMethodName="by_user_name") - email_address = UnicodeCol(length=255, alternateID=True, - alternateMethodName="by_email_address") - display_name = UnicodeCol(length=255) - password = UnicodeCol(length=40) - created = DateTimeCol(default=datetime.now) - - # groups this user belongs to - groups = RelatedJoin("Group", intermediateTable="user_group", - joinColumn="user_id", otherColumn="group_id") - - def _get_permissions(self): - perms = set() - for g in self.groups: - perms = perms | set(g.permissions) - return perms - - def _set_password(self, cleartext_password): - "Runs cleartext_password through the hash algorithm before saving." - hash = identity.encrypt_password(cleartext_password) - self._SO_set_password(hash) - - def set_password_raw(self, password): - "Saves the password as-is to the database." - self._SO_set_password(password) - - - -class Permission(SQLObject): - permission_name = UnicodeCol(length=16, alternateID=True, - alternateMethodName="by_permission_name") - description = UnicodeCol(length=255) - - groups = RelatedJoin("Group", - intermediateTable="group_permission", - joinColumn="permission_id", - otherColumn="group_id") - - diff --git a/examples/turbogears/genshitest/release.py b/examples/turbogears/genshitest/release.py deleted file mode 100644 --- a/examples/turbogears/genshitest/release.py +++ /dev/null @@ -1,14 +0,0 @@ -# Release information about GenshiTest - -version = "1.0" - -# description = "Your plan to rule the world" -# long_description = "More description about your plan" -# author = "Your Name Here" -# email = "YourEmail@YourDomain" -# copyright = "Vintage 2006 - a good year indeed" - -# if it's open source, you might want to specify these -# url = "http://yourcool.site/" -# download_url = "http://yourcool.site/download" -# license = "MIT" diff --git a/examples/turbogears/genshitest/static/images/favicon.ico b/examples/turbogears/genshitest/static/images/favicon.ico deleted file mode 100644 index 332557bc307647601389c14939be0671c62efcd7..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 GIT binary patch literal 0 Hc$@ - - - - - - - Login - - - - -
-

Login

-

$message

-
- - - - - - - - - - - - -
- - - -
- - - -
- -
- - - - -
-
- - diff --git a/examples/turbogears/genshitest/templates/master.html b/examples/turbogears/genshitest/templates/master.html deleted file mode 100644 --- a/examples/turbogears/genshitest/templates/master.html +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - Your title goes here - - - - - -
- - Login - - - Welcome ${tg.identity.user.display_name}. - Logout - -
-
-
-

TurboGears under the hood

- - - diff --git a/examples/turbogears/genshitest/templates/plain.txt b/examples/turbogears/genshitest/templates/plain.txt deleted file mode 100644 --- a/examples/turbogears/genshitest/templates/plain.txt +++ /dev/null @@ -1,8 +0,0 @@ -#choose - #when name - Hello, $name! - #end - #otherwise - Hello, anonymous! - #end -#end diff --git a/examples/turbogears/genshitest/templates/sitetemplate.html b/examples/turbogears/genshitest/templates/sitetemplate.html deleted file mode 100644 --- a/examples/turbogears/genshitest/templates/sitetemplate.html +++ /dev/null @@ -1,18 +0,0 @@ - - - - - Your title goes here - - - - - -
-
-
- - diff --git a/examples/turbogears/genshitest/templates/welcome.html b/examples/turbogears/genshitest/templates/welcome.html deleted file mode 100644 --- a/examples/turbogears/genshitest/templates/welcome.html +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - Welcome to TurboGears - - - -

Congratulations, your TurboGears application is running as of - now.

- -

Using Genshi in TurboGears

- -

- Please see the online - documentation - for general information on Genshi. -

- -

Here's an example for using a TurboGears widget in a Genshi template:

- ${ET(widget.display())} - -

- And here's a link to the output of a plain-text - template. -

- - - diff --git a/examples/turbogears/genshitest/tests/__init__.py b/examples/turbogears/genshitest/tests/__init__.py deleted file mode 100644 diff --git a/examples/turbogears/genshitest/tests/test_controllers.py b/examples/turbogears/genshitest/tests/test_controllers.py deleted file mode 100644 --- a/examples/turbogears/genshitest/tests/test_controllers.py +++ /dev/null @@ -1,16 +0,0 @@ -from turbogears import testutil -from genshitest.controllers import Root -import cherrypy - -cherrypy.root = Root() - -def test_method(): - "the index method should return a string called now" - import types - result = testutil.call(cherrypy.root.index) - assert type(result["now"]) == types.StringType - -def test_indextitle(): - "The mainpage should have the right title" - testutil.createRequest("/") - assert "Welcome to TurboGears" in cherrypy.response.body[0] diff --git a/examples/turbogears/genshitest/tests/test_model.py b/examples/turbogears/genshitest/tests/test_model.py deleted file mode 100644 --- a/examples/turbogears/genshitest/tests/test_model.py +++ /dev/null @@ -1,23 +0,0 @@ -# If your project uses a database, you can set up database tests -# similar to what you see below. Be sure to set the db_uri to -# an appropriate uri for your testing database. sqlite is a good -# choice for testing, because you can use an in-memory database -# which is very fast. - -from turbogears import testutil -# from genshitest.model import YourDataClass, User - -# database.set_db_uri("sqlite:///:memory:") - -# class TestUser(testutil.DBTest): -# def get_model(self): -# return User -# -# def test_creation(self): -# "Object creation should set the name" -# obj = User(user_name = "creosote", -# email_address = "spam@python.not", -# display_name = "Mr Creosote", -# password = "Wafer-thin Mint") -# assert obj.display_name == "Mr Creosote" - diff --git a/examples/turbogears/sample-prod.cfg b/examples/turbogears/sample-prod.cfg deleted file mode 100644 --- a/examples/turbogears/sample-prod.cfg +++ /dev/null @@ -1,69 +0,0 @@ -[global] -# This is where all of your settings go for your production environment. -# You'll copy this file over to your production server and provide it -# as a command-line option to your start script. -# Settings that are the same for both development and production -# (such as template engine, encodings, etc.) all go in -# genshitest/config/app.cfg - -# pick the form for your database -# sqlobject.dburi="postgres://username@hostname/databasename" -# sqlobject.dburi="mysql://username:password@hostname:port/databasename" -# sqlobject.dburi="sqlite:///file_name_and_path" - -# If you have sqlite, here's a simple default to get you started -# in development -sqlobject.dburi="sqlite://%(current_dir_uri)s/devdata.sqlite" - - -# if you are using a database or table type without transactions -# (MySQL default, for example), you should turn off transactions -# by prepending notrans_ on the uri -# sqlobject.dburi="notrans_mysql://username:password@hostname:port/databasename" - -# for Windows users, sqlite URIs look like: -# sqlobject.dburi="sqlite:///drive_letter:/path/to/file" - - -# SERVER - -server.environment="production" - -# Sets the number of threads the server uses -# server.thread_pool = 1 - -# if this is part of a larger site, you can set the path -# to the TurboGears instance here -# server.webpath="" - -# Set to True if you'd like to abort execution if a controller gets an -# unexpected parameter. False by default -# tg.strict_parameters = False - -# LOGGING -# Logging configuration generally follows the style of the standard -# Python logging module configuration. Note that when specifying -# log format messages, you need to use *() for formatting variables. -# Deployment independent log configuration is in genshitest/config/log.cfg -[logging] - -[[handlers]] - -[[[access_out]]] -# set the filename as the first argument below -args="('server.log',)" -class='FileHandler' -level='INFO' -formatter='message_only' - -[[loggers]] -[[[genshitest]]] -level='ERROR' -qualname='genshitest' -handlers=['error_out'] - -[[[access]]] -level='INFO' -qualname='turbogears.access' -handlers=['access_out'] -propagate=0 diff --git a/examples/turbogears/setup.py b/examples/turbogears/setup.py deleted file mode 100644 --- a/examples/turbogears/setup.py +++ /dev/null @@ -1,62 +0,0 @@ -from setuptools import setup, find_packages -from turbogears.finddata import find_package_data - -import os -execfile(os.path.join("genshitest", "release.py")) - -setup( - name="GenshiTest", - version=version, - - # uncomment the following lines if you fill them out in release.py - #description=description, - #author=author, - #author_email=email, - #url=url, - #download_url=download_url, - #license=license, - - install_requires = [ - "TurboGears >= 0.9a9dev-r1686", - ], - scripts = ["start-genshitest.py"], - zip_safe=False, - packages=find_packages(), - package_data = find_package_data(where='genshitest', - package='genshitest'), - keywords = [ - # Use keywords if you'll be adding your package to the - # Python Cheeseshop - - # if this has widgets, uncomment the next line - # 'turbogears.widgets', - - # if this has a tg-admin command, uncomment the next line - # 'turbogears.command', - - # if this has identity providers, uncomment the next line - # 'turbogears.identity.provider', - - # If this is a template plugin, uncomment the next line - # 'python.templating.engines', - - # If this is a full application, uncomment the next line - # 'turbogears.app', - ], - classifiers = [ - 'Development Status :: 3 - Alpha', - 'Operating System :: OS Independent', - 'Programming Language :: Python', - 'Topic :: Software Development :: Libraries :: Python Modules', - 'Framework :: TurboGears', - # if this is an application that you'll distribute through - # the Cheeseshop, uncomment the next line - # 'Framework :: TurboGears :: Applications', - - # if this is a package that includes widgets that you'll distribute - # through the Cheeseshop, uncomment the next line - # 'Framework :: TurboGears :: Widgets', - ], - test_suite = 'nose.collector', - ) - diff --git a/examples/turbogears/start-genshitest.py b/examples/turbogears/start-genshitest.py deleted file mode 100755 --- a/examples/turbogears/start-genshitest.py +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/python -import pkg_resources -pkg_resources.require("TurboGears") - -import turbogears -import cherrypy -cherrypy.lowercase_api = True - -from os.path import * -import sys - -# first look on the command line for a desired config file, -# if it's not on the command line, then -# look for setup.py in this directory. If it's not there, this script is -# probably installed -if len(sys.argv) > 1: - turbogears.update_config(configfile=sys.argv[1], - modulename="genshitest.config") -elif exists(join(dirname(__file__), "setup.py")): - turbogears.update_config(configfile="dev.cfg", - modulename="genshitest.config") -else: - turbogears.update_config(configfile="prod.cfg", - modulename="genshitest.config") - -from genshitest.controllers import Root - -turbogears.start_server(Root())