diff options
| author | ianb <devnull@localhost> | 2005-05-16 03:15:01 +0000 |
|---|---|---|
| committer | ianb <devnull@localhost> | 2005-05-16 03:15:01 +0000 |
| commit | 4a290bd14e83c30d8803f06ac45e3317fe6b47ed (patch) | |
| tree | a1503e37367784112cf14e2914457c83579daed7 /paste/app_templates | |
| parent | c5b70bfda8c8e58b83c2f073228d65770c21a604 (diff) | |
| download | paste-4a290bd14e83c30d8803f06ac45e3317fe6b47ed.tar.gz | |
Added new template for Wareweb/ZPT
Diffstat (limited to 'paste/app_templates')
14 files changed, 187 insertions, 0 deletions
diff --git a/paste/app_templates/wareweb_zpt/__init__.py b/paste/app_templates/wareweb_zpt/__init__.py new file mode 100644 index 0000000..792d600 --- /dev/null +++ b/paste/app_templates/wareweb_zpt/__init__.py @@ -0,0 +1 @@ +# diff --git a/paste/app_templates/wareweb_zpt/command.py b/paste/app_templates/wareweb_zpt/command.py new file mode 100644 index 0000000..dff1b60 --- /dev/null +++ b/paste/app_templates/wareweb_zpt/command.py @@ -0,0 +1,43 @@ +import os +from paste import app_setup +from paste import pyconfig + +the_runner = app_setup.CommandRunner() +the_runner.register(app_setup.CommandCreate) + +class CommandServlet(app_setup.Command): + + name = 'servlet' + summary = 'Create a new servlet and template' + max_args = 1 + min_args = 1 + + parser = app_setup.standard_parser() + + def command(self): + servlet_fn = os.path.splitext(self.args[0])[0] + config = {} + if '/' in servlet_fn or '\\' in servlet_fn: + servlet_name = os.path.basename(servlet_fn) + else: + servlet_name = servlet_fn + if self.runner.server_conf_fn: + output_dir = os.path.dirname(self.runner.server_conf_fn) + config = pyconfig.Config() + config.load(self.runner.server_conf_fn) + else: + output_dir = os.getcwd() + source_dir = os.path.join(self.template_dir, 'servlet_template') + template_options = config.copy() + template_options.update(self.options.__dict__) + template_options.update({ + 'servlet_name': servlet_name, + 'servlet_fn': servlet_fn, + }) + app_setup.copy_dir( + source_dir, output_dir, template_options, + self.options.verbose, self.options.simulate) + +the_runner.register(CommandServlet) + +run = the_runner.run diff --git a/paste/app_templates/wareweb_zpt/description.txt b/paste/app_templates/wareweb_zpt/description.txt new file mode 100644 index 0000000..c28a3d5 --- /dev/null +++ b/paste/app_templates/wareweb_zpt/description.txt @@ -0,0 +1,4 @@ +Wareweb and Zope Page Template framework + +This sets up a basic Wareweb application, using Zope Page Templates +(with ZPTKit). diff --git a/paste/app_templates/wareweb_zpt/servlet_template/templates/+servlet_name+.pt b/paste/app_templates/wareweb_zpt/servlet_template/templates/+servlet_name+.pt new file mode 100644 index 0000000..e2825e5 --- /dev/null +++ b/paste/app_templates/wareweb_zpt/servlet_template/templates/+servlet_name+.pt @@ -0,0 +1,7 @@ +<html metal:use-macro="here/standard_template.pt/macros/page"> +<metal:body fill-slot="body"> + + + +</metal:body> +</html>
\ No newline at end of file diff --git a/paste/app_templates/wareweb_zpt/servlet_template/web/+servlet_name+.py b/paste/app_templates/wareweb_zpt/servlet_template/web/+servlet_name+.py new file mode 100644 index 0000000..ee94338 --- /dev/null +++ b/paste/app_templates/wareweb_zpt/servlet_template/web/+servlet_name+.py @@ -0,0 +1,7 @@ +from $app_name.sitepage import SitePage + +class $servlet_name(SitePage): + + def setup(self): + self.title = $str_servlet_name + diff --git a/paste/app_templates/wareweb_zpt/template/__init__.py b/paste/app_templates/wareweb_zpt/template/__init__.py new file mode 100644 index 0000000..1cb2d1b --- /dev/null +++ b/paste/app_templates/wareweb_zpt/template/__init__.py @@ -0,0 +1,4 @@ +from paste.util.thirdparty import add_package + +add_package('ZopePageTemplates') +add_package('ZPTKit') diff --git a/paste/app_templates/wareweb_zpt/template/server.conf b/paste/app_templates/wareweb_zpt/template/server.conf new file mode 100644 index 0000000..46cabf4 --- /dev/null +++ b/paste/app_templates/wareweb_zpt/template/server.conf @@ -0,0 +1,20 @@ +# -*- python -*- Note: this file is in Python syntax + +import os + +app_template = $str_template_name +app_name = $str_app_name +root_path = $str_absolute_base_dir +publish_dir = os.path.join(root_path, 'web') +sys_path = [os.path.dirname(root_path)] + +## Server options: + +verbose = $bool_verbose +# The name of the server-type to start: +server = $str_server +# If true, files will be regularly polled and the server restarted +# if files are modified: +reload = $bool_reload +# If true, tracebacks will be shown in the browser: +debug = $bool_debug diff --git a/paste/app_templates/wareweb_zpt/template/sitepage.py b/paste/app_templates/wareweb_zpt/template/sitepage.py new file mode 100644 index 0000000..fad80d9 --- /dev/null +++ b/paste/app_templates/wareweb_zpt/template/sitepage.py @@ -0,0 +1,13 @@ +from paste.wareweb import * +from ZPTKit.zptwareweb import ZPTComponent + +class SitePage(Servlet): + + message = Notify() + template = ZPTComponent() + app_name = $str_app_name + +# This protects "from sitepage import *", since we will no longer +# need these variables: +del ZPTComponent +del Notify diff --git a/paste/app_templates/wareweb_zpt/template/templates/generic_error.pt b/paste/app_templates/wareweb_zpt/template/templates/generic_error.pt new file mode 100644 index 0000000..7b32820 --- /dev/null +++ b/paste/app_templates/wareweb_zpt/template/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/paste/app_templates/wareweb_zpt/template/templates/index.pt b/paste/app_templates/wareweb_zpt/template/templates/index.pt new file mode 100644 index 0000000..ff16ada --- /dev/null +++ b/paste/app_templates/wareweb_zpt/template/templates/index.pt @@ -0,0 +1,22 @@ +<html metal:use-macro="here/standard_template.pt/macros/page"> +<metal:body fill-slot="body"> + +<p> +Congratulations, you have set up your new application instance. +This page serves as an example; feel free to overwrite it. +</p> + +<p> +These are all the environmental variables defined: +</p> + +<table border=1> + <tr tal:repeat="var options/vars"> + <td tal:content="python: var[0]">Var Name</td> + <td><tt tal:content="python: var[1]">Var value</tt></td> + </tr> +</table> + + +</metal:body> +</html>
\ No newline at end of file diff --git a/paste/app_templates/wareweb_zpt/template/templates/standard_template.pt b/paste/app_templates/wareweb_zpt/template/templates/standard_template.pt new file mode 100644 index 0000000..8733ae1 --- /dev/null +++ b/paste/app_templates/wareweb_zpt/template/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.app_static_url + '/stylesheet.css'"> + +<metal:slot define-slot="extra_head"></metal:slot> + +</head> +<body> + +<h1><tal:mark replace="servlet/title"/></h1> + +<div class="notifyMessage" + tal:condition="servlet/message" + tal:content="structure/message/html"> + [This is where the notification messages go] +</div> + +<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/paste/app_templates/wareweb_zpt/template/web/__init__.py b/paste/app_templates/wareweb_zpt/template/web/__init__.py new file mode 100644 index 0000000..1454f37 --- /dev/null +++ b/paste/app_templates/wareweb_zpt/template/web/__init__.py @@ -0,0 +1,6 @@ +import os +from paste import wsgilib + +def urlparser_hook(environ): + if not environ.has_key('${app_name}.base_url'): + environ['${app_name}.base_url'] = environ['SCRIPT_NAME'] diff --git a/paste/app_templates/wareweb_zpt/template/web/index.py b/paste/app_templates/wareweb_zpt/template/web/index.py new file mode 100644 index 0000000..6144e17 --- /dev/null +++ b/paste/app_templates/wareweb_zpt/template/web/index.py @@ -0,0 +1,9 @@ +from $app_name.sitepage import SitePage + +class index(SitePage): + + def setup(self): + self.options.vars = self.environ.items() + self.options.vars.sort() + self.title = 'Welcome to your new app' + diff --git a/paste/app_templates/wareweb_zpt/template/web/static/stylesheet.css b/paste/app_templates/wareweb_zpt/template/web/static/stylesheet.css new file mode 100644 index 0000000..d70e9ec --- /dev/null +++ b/paste/app_templates/wareweb_zpt/template/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; +} |
