1. Jan Brohl
  2. templates4scoutnet

Commits

Jan Brohl  committed e438591

umstrukturieren...

  • Participants
  • Parent commits 140505a
  • Branches default

Comments (0)

Files changed (9)

File license.txt

View file
  • Ignore whitespace
+Copyright (c) 2012, Jan Brohl <janbrohl@t-online.de>
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+    Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+    Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

File src/license.txt

  • Ignore whitespace
-Copyright (c) 2012, Jan Brohl <janbrohl@t-online.de>
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
-
-    Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
-    Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

File src/main.py

  • Ignore whitespace
-'''
-Created on 01.07.2012
-
-@author: Jan Brohl <janbrohl@t-online.de>
-@license: Simplified BSD License see license.txt
-@copyright: Copyright (c) 2012, Jan Brohl <janbrohl@t-online.de>. All rights reserved.
-'''
-
-from scoutnet.lazyapi import Lazy
-from werkzeug.wrappers import Response, Request
-from simpletal.simpleTAL import compileHTMLTemplate
-from simpletal.simpleTALES import Context
-from urllib import urlopen
-from cStringIO import StringIO
-from simplerest.util import NoCallWrapper, TALVirtualPath
-from urlparse import urlsplit, urlunsplit
-
-template_pfad = "http://localhost/templates4scoutnet/templates/" # oder sowas in der art
-
-@Request.application
-def application(request):
-    charset = request.charset or "UTF-8"
-    args = request.args
-    template_url = args.get("template", None)
-    if template_url:
-        tu_parts = urlsplit(template_url)
-        if tu_parts.scheme:
-            pp = urlunsplit(tu_parts[:2] + ([""] * 3))
-        else:
-            pp = template_pfad
-        bp = tu_parts[2].strip("/")
-        if bp:
-            bp = bp.split("/")
-            path = bp.pop(-1) + tu_parts[3]
-        else:
-            bp = []
-            path = tu_parts[3]
-        tvp = TemplateVirtualPath(path=[], basepath=bp, path_prefix=pp)
-        template = tvp[path]()
-        wrapper = TemplateWrapper(tvp)
-    else:
-        wrapper = None
-        f = open("default.pt")
-        incharset = "UTF-8"
-        template = compileHTMLTemplate(f, incharset)
-        f.close()
-    ctx = NoCallWrapper(Lazy(path=args["context"]))
-    d = dict(args.to_dict(False))
-    s = render(template, d, ctx, wrapper, charset)
-    return Response(s, content_type="text/html;charset=" + charset)
-
-class TemplateVirtualPath(TALVirtualPath):
-    def __call__(self):
-        f = urlopen(self.kwarg("path_prefix") + self.path_as_list)
-        incharset = f.info().getparam("charset")
-        return compileHTMLTemplate(f, incharset)
-
-class TemplateWrapper(NoCallWrapper):
-    def macros(self):
-        return self().macros
-
-def render(template, options, context, container, charset):
-    ctx = Context(options)
-    ctx.addGlobal("context", context)
-    ctx.addGlobal("container", container)
-    f = StringIO()
-    template.expand(ctx, f, charset)
-    return f.getvalue()
-

File src/server.py

  • Ignore whitespace
-'''
-Created on 01.07.2012
-
-@author: Jan
-'''
-import wsgiref.simple_server
-import main
-
-try:
-    server = wsgiref.simple_server.make_server("localhost", 80, main.application)
-    server.serve_forever()
-finally:
-    server.close()

File src/templates4scoutnet/__init__.py

View file
  • Ignore whitespace
+from main import application

File src/templates4scoutnet/examples/__init__.py

  • Ignore whitespace
Empty file added.

File src/templates4scoutnet/examples/cgi.py

View file
  • Ignore whitespace
+#!/usr/bin/env python
+from wsgiref.handlers import CGIHandler
+from templates4scoutnet import application
+CGIHandler().run(application)

File src/templates4scoutnet/examples/wsgiserver.py

View file
  • Ignore whitespace
+'''
+Created on 01.07.2012
+
+@author: Jan
+'''
+import wsgiref.simple_server
+from templates4scoutnet import application
+
+try:
+    server = wsgiref.simple_server.make_server("localhost", 80, application)
+    server.serve_forever()
+finally:
+    server.close()

File src/templates4scoutnet/main.py

View file
  • Ignore whitespace
+'''
+Created on 01.07.2012
+
+@author: Jan Brohl <janbrohl@t-online.de>
+@license: Simplified BSD License see license.txt
+@copyright: Copyright (c) 2012, Jan Brohl <janbrohl@t-online.de>. All rights reserved.
+'''
+
+from scoutnet.lazyapi import Lazy
+from werkzeug.wrappers import Response, Request
+from simpletal.simpleTAL import compileHTMLTemplate
+from simpletal.simpleTALES import Context
+from urllib import urlopen
+from cStringIO import StringIO
+from simplerest.util import NoCallWrapper, TALVirtualPath
+from urlparse import urlsplit, urlunsplit
+
+template_pfad = "http://localhost/templates4scoutnet/templates/" # oder sowas in der art
+
+@Request.application
+def application(request):
+    charset = request.charset or "UTF-8"
+    args = request.args
+    template_url = args.get("template", None)
+    if template_url:
+        tu_parts = urlsplit(template_url)
+        if tu_parts.scheme:
+            pp = urlunsplit(tu_parts[:2] + ([""] * 3))
+        else:
+            pp = template_pfad
+        bp = tu_parts[2].strip("/")
+        if bp:
+            bp = bp.split("/")
+            path = bp.pop(-1) + tu_parts[3]
+        else:
+            bp = []
+            path = tu_parts[3]
+        tvp = TemplateVirtualPath(path=[], basepath=bp, path_prefix=pp)
+        template = tvp[path]()
+        wrapper = TemplateWrapper(tvp)
+    else:
+        wrapper = None
+        f = open("default.pt")
+        incharset = "UTF-8"
+        template = compileHTMLTemplate(f, incharset)
+        f.close()
+    ctx = NoCallWrapper(Lazy(path=args["context"]))
+    d = dict(args.to_dict(False))
+    s = render(template, d, ctx, wrapper, charset)
+    return Response(s, content_type="text/html;charset=" + charset)
+
+class TemplateVirtualPath(TALVirtualPath):
+    def __call__(self):
+        f = urlopen(self.kwarg("path_prefix") + self.path_as_list)
+        incharset = f.info().getparam("charset")
+        return compileHTMLTemplate(f, incharset)
+
+class TemplateWrapper(NoCallWrapper):
+    def macros(self):
+        return self().macros
+
+def render(template, options, context, container, charset):
+    ctx = Context(options)
+    ctx.addGlobal("context", context)
+    ctx.addGlobal("container", container)
+    f = StringIO()
+    template.expand(ctx, f, charset)
+    return f.getvalue()
+