From 65e95da78f4f3360bb022fdc5c0cbecba2495d3d Mon Sep 17 00:00:00 2001 From: ianb Date: Mon, 2 May 2005 04:26:59 +0000 Subject: Removed spaces from name (#6) --- examples/console/__init__.py | 5 +++ examples/console/server.conf | 19 +++++++++ examples/console/sitepage.py | 41 +++++++++++++++++++ examples/console/templates/generic_error.pt | 7 ++++ examples/console/templates/index.pt | 36 +++++++++++++++++ examples/console/templates/standard_template.pt | 31 +++++++++++++++ examples/console/web/__init__.py | 6 +++ examples/console/web/index.py | 18 +++++++++ examples/console/web/static/command.js | 25 ++++++++++++ examples/console/web/static/stylesheet.css | 13 +++++++ setup.py | 52 ++++++++++++------------- 11 files changed, 227 insertions(+), 26 deletions(-) create mode 100644 examples/console/__init__.py create mode 100644 examples/console/server.conf create mode 100644 examples/console/sitepage.py create mode 100644 examples/console/templates/generic_error.pt create mode 100644 examples/console/templates/index.pt create mode 100644 examples/console/templates/standard_template.pt create mode 100644 examples/console/web/__init__.py create mode 100644 examples/console/web/index.py create mode 100644 examples/console/web/static/command.js create mode 100644 examples/console/web/static/stylesheet.css 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 @@ + + + + + + + \ 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 @@ + + + + + + + + + + +
+ +Run:
+
+Multiline commands:
+ + +Output:
+
+
+
+ +
+ +
+ \ 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 @@ + + + + +title + + + + + + + + + +

+ + +This is where the notification messages go. + + +
+ +[This page has not customized its "body" slot] + +
+ + + +
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 += '
\n' + '' + + command + ''; + if (result != nil) { + output_html += '
\n' + '' + + result + ''; + } + 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; +} diff --git a/setup.py b/setup.py index 3bdeb67..4571da5 100644 --- a/setup.py +++ b/setup.py @@ -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: -- cgit v1.2.1