Jan Brohl avatar Jan Brohl committed e438591

umstrukturieren...

Comments (0)

Files changed (9)

+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.

src/license.txt

-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.

src/main.py

-'''
-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()
-

src/server.py

-'''
-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()

src/templates4scoutnet/__init__.py

+from main import application
Add a comment to this file

src/templates4scoutnet/examples/__init__.py

Empty file added.

src/templates4scoutnet/examples/cgi.py

+#!/usr/bin/env python
+from wsgiref.handlers import CGIHandler
+from templates4scoutnet import application
+CGIHandler().run(application)

src/templates4scoutnet/examples/wsgiserver.py

+'''
+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()

src/templates4scoutnet/main.py

+'''
+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()
+
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.