summaryrefslogtreecommitdiff
path: root/examples/console
diff options
context:
space:
mode:
authorianb <devnull@localhost>2005-05-02 04:26:59 +0000
committerianb <devnull@localhost>2005-05-02 04:26:59 +0000
commit65e95da78f4f3360bb022fdc5c0cbecba2495d3d (patch)
tree4f1cce59485880e5c6a29c62a597629fea2c035a /examples/console
parent760d39273ea2158b763504bb8660c3a6a6582a7e (diff)
downloadpaste-65e95da78f4f3360bb022fdc5c0cbecba2495d3d.tar.gz
Removed spaces from name (#6)
Diffstat (limited to 'examples/console')
-rw-r--r--examples/console/__init__.py5
-rw-r--r--examples/console/server.conf19
-rw-r--r--examples/console/sitepage.py41
-rw-r--r--examples/console/templates/generic_error.pt7
-rw-r--r--examples/console/templates/index.pt36
-rw-r--r--examples/console/templates/standard_template.pt31
-rw-r--r--examples/console/web/__init__.py6
-rw-r--r--examples/console/web/index.py18
-rw-r--r--examples/console/web/static/command.js25
-rw-r--r--examples/console/web/static/stylesheet.css13
10 files changed, 201 insertions, 0 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;
+}