diff options
| author | ianb <devnull@localhost> | 2005-05-02 04:26:59 +0000 |
|---|---|---|
| committer | ianb <devnull@localhost> | 2005-05-02 04:26:59 +0000 |
| commit | 65e95da78f4f3360bb022fdc5c0cbecba2495d3d (patch) | |
| tree | 4f1cce59485880e5c6a29c62a597629fea2c035a | |
| parent | 760d39273ea2158b763504bb8660c3a6a6582a7e (diff) | |
| download | paste-65e95da78f4f3360bb022fdc5c0cbecba2495d3d.tar.gz | |
Removed spaces from name (#6)
| -rw-r--r-- | examples/console/__init__.py | 5 | ||||
| -rw-r--r-- | examples/console/server.conf | 19 | ||||
| -rw-r--r-- | examples/console/sitepage.py | 41 | ||||
| -rw-r--r-- | examples/console/templates/generic_error.pt | 7 | ||||
| -rw-r--r-- | examples/console/templates/index.pt | 36 | ||||
| -rw-r--r-- | examples/console/templates/standard_template.pt | 31 | ||||
| -rw-r--r-- | examples/console/web/__init__.py | 6 | ||||
| -rw-r--r-- | examples/console/web/index.py | 18 | ||||
| -rw-r--r-- | examples/console/web/static/command.js | 25 | ||||
| -rw-r--r-- | examples/console/web/static/stylesheet.css | 13 | ||||
| -rw-r--r-- | setup.py | 52 |
11 files changed, 227 insertions, 26 deletions
diff --git a/examples/console/__init__.py b/examples/console/__init__.py new file mode 100644 index 0000000..0454673 --- /dev/null +++ b/examples/console/__init__.py @@ -0,0 +1,5 @@ +from paste.util.thirdparty import add_package + +add_package('ZopePageTemplates') +add_package('Component') +add_package('ZPTKit') diff --git a/examples/console/server.conf b/examples/console/server.conf new file mode 100644 index 0000000..3ef5cc0 --- /dev/null +++ b/examples/console/server.conf @@ -0,0 +1,19 @@ +# -*- python -*- Note: this file is in Python syntax + +import os + +app_template = 'webkit_zpt' +app_name = 'console' +publish_dir = os.path.join('/home/ianb/svn.w4py.org/Paste/trunk/examples/console', 'web') +sys_path = ['/home/ianb/svn.w4py.org/Paste/trunk/examples'] + +## Server options: + +verbose = False +# 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 diff --git a/examples/console/sitepage.py b/examples/console/sitepage.py new file mode 100644 index 0000000..b7f7f33 --- /dev/null +++ b/examples/console/sitepage.py @@ -0,0 +1,41 @@ +import os +from Component import CPage +from Component.notify import NotifyComponent +from ZPTKit import ZPTComponent +from paste import httpexceptions + +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) + env = trans.request().environ() + if env['REMOTE_ADDR'] != '127.0.0.1': + raise httpexceptions.HTTPForbidden + if env['wsgi.multiprocess'] or env['wsgi.run_once']: + raise httpexceptions.HTTPServerError( + 'This application can only be run under single-process ' + '(typically multi-threaded) long-running servers') + self.baseURL = self.request().environ()['console.base_url'] + self.baseStaticURL = self.baseURL + '/static' + 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/console/templates/generic_error.pt b/examples/console/templates/generic_error.pt new file mode 100644 index 0000000..7b32820 --- /dev/null +++ b/examples/console/templates/generic_error.pt @@ -0,0 +1,7 @@ +<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/console/templates/index.pt b/examples/console/templates/index.pt new file mode 100644 index 0000000..3c76768 --- /dev/null +++ b/examples/console/templates/index.pt @@ -0,0 +1,36 @@ +<html metal:use-macro="here/standard_template.pt/macros/page"> +<metal:js fill-slot="extra_head"> + +<script type="text/javascript" + tal:attributes="src python: servlet.baseStaticURL + + '/command.js'"></script> + +<style type="text/css"> +.input { + color: #006600; +} +.output { + color: #000066; +} +</style> + +</metal:js> +<metal:body fill-slot="body"> + +<form onsubmit="return send_command()"> + +Run:<br> +<input type="text" style="width: 100%" id="command"><br> +Multiline commands:<br> +<textarea rows=4 cols=50 style="width: 100%" id="command_long"></textarea> + +Output:<br> +<div id="output" style="width: 100%; border: 1px solid black; + background-color: #ddddff"> +<br> +</div> + +</form> + +</metal:body> +</html>
\ No newline at end of file diff --git a/examples/console/templates/standard_template.pt b/examples/console/templates/standard_template.pt new file mode 100644 index 0000000..10b2ac1 --- /dev/null +++ b/examples/console/templates/standard_template.pt @@ -0,0 +1,31 @@ +<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> + +<tal:insert replace="structure servlet/jsonjs" /> + +</head> +<body> + +<h1><tal:mark replace="servlet/title"/></h1> + +<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> + +</body> +</html> +</metal:tpl> diff --git a/examples/console/web/__init__.py b/examples/console/web/__init__.py new file mode 100644 index 0000000..acd5c7a --- /dev/null +++ b/examples/console/web/__init__.py @@ -0,0 +1,6 @@ +import os +from paste import wsgilib + +def urlparser_hook(environ): + if not environ.has_key('console.base_url'): + environ['console.base_url'] = environ['SCRIPT_NAME'] diff --git a/examples/console/web/index.py b/examples/console/web/index.py new file mode 100644 index 0000000..81f2759 --- /dev/null +++ b/examples/console/web/index.py @@ -0,0 +1,18 @@ +from console.sitepage import SitePage +from console.JSONComponent import JSONComponent + +global_namespace = {} + +class index(SitePage): + + components = SitePage.components + [ + JSONComponent(baseConfig='console')] + + def setup(self): + self.options.title = 'Console' + + def jsonMethods(self): + return ['run'] + + def run(self): + return 'Cool dude!' diff --git a/examples/console/web/static/command.js b/examples/console/web/static/command.js new file mode 100644 index 0000000..5b592fd --- /dev/null +++ b/examples/console/web/static/command.js @@ -0,0 +1,25 @@ +output_html = '' + +function send_command() { + var command_short = document.getElementById('command'); + var command_long = document.getElementById('command_long'); + var command = command_short.value; + if (command == '') { + command = command_long.value; + } + if (command == '') { + return false; + } + command_short.value = ''; + command_long.value = ''; + var result = servlet.run(command); + var output_div = document.getElementById('output'); + output_html += '<br>\n' + '<span class="input">' + + command + '</span>'; + if (result != nil) { + output_html += '<br>\n' + '<span class="output">' + + result + '</span>'; + } + output_div.innerHTML = output_html; + return false; +} diff --git a/examples/console/web/static/stylesheet.css b/examples/console/web/static/stylesheet.css new file mode 100644 index 0000000..d70e9ec --- /dev/null +++ b/examples/console/web/static/stylesheet.css @@ -0,0 +1,13 @@ +body { + font-family: Helvetica, Arial, sans-serif; +} + +pre { + overflow: auto; +} + +div.notifyMessage { + border: 2px solid black; + background-color: #007700; + color: #ffffff; +} @@ -1,7 +1,7 @@ -from distutils.core import setup
+from distutils.core import setup from distutils import sysconfig import warnings -warnings.filterwarnings("ignore", "Unknown distribution option")
+warnings.filterwarnings("ignore", "Unknown distribution option") import sys # patch distutils if it can't cope with the "classifiers" keyword @@ -9,27 +9,27 @@ if sys.version < '2.2.3': from distutils.dist import DistributionMetadata DistributionMetadata.classifiers = None DistributionMetadata.download_url = None -
-import os
-
-BASEDIR = os.path.split(os.path.abspath(__file__))[0]
-
-def get_data_files(path, files = []):
- l = []
- for name in os.listdir(path):
- if name[0] == ".":
- continue
- relpath = os.path.join(path, name)
- f = os.path.join(BASEDIR, relpath)
- if os.path.isdir(f):
- get_data_files(relpath, files)
- elif os.path.isfile(f):
- l.append(f)
- pref = sysconfig.get_python_lib()[len(sysconfig.PREFIX) + 1:]
- files.append((os.path.join(pref, path), l))
- return files
-setup(name="Python Paste", +import os + +BASEDIR = os.path.split(os.path.abspath(__file__))[0] + +def get_data_files(path, files = []): + l = [] + for name in os.listdir(path): + if name[0] == ".": + continue + relpath = os.path.join(path, name) + f = os.path.join(BASEDIR, relpath) + if os.path.isdir(f): + get_data_files(relpath, files) + elif os.path.isfile(f): + l.append(f) + pref = sysconfig.get_python_lib()[len(sysconfig.PREFIX) + 1:] + files.append((os.path.join(pref, path), l)) + return files + +setup(name="Paste", version="0.1", description="Tools for use with a Web Server Gateway Interface stack", long_description="""\ @@ -58,16 +58,16 @@ functionality. url="http://webwareforpython.org", license="PSF", packages=["paste", "paste.exceptions", - "paste.util",
+ "paste.util", "paste.webkit", "paste.webkit.FakeWebware", "paste.webkit.FakeWebware.WebKit", "paste.webkit.FakeWebware.WebUtils", "paste.webkit.FakeWebware.MiscUtils"], scripts=['scripts/paste-server', 'scripts/paste-setup'], - download_url="",
- data_files=get_data_files(os.path.join("paste","app_templates")) +
- [(os.path.join(sysconfig.get_python_lib()[len(sysconfig.PREFIX) + 1:], "paste"), [os.path.join("paste", "default_config.conf")])]
+ download_url="", + data_files=get_data_files(os.path.join("paste","app_templates")) + + [(os.path.join(sysconfig.get_python_lib()[len(sysconfig.PREFIX) + 1:], "paste"), [os.path.join("paste", "default_config.conf")])] ) # Send announce to: |
