diff --git a/web/README.txt b/web/README.txt deleted file mode 100644 index b103071..0000000 --- a/web/README.txt +++ /dev/null @@ -1,27 +0,0 @@ -=============================== -All about Views, Templates, ... -=============================== - -$Id$ - - -Generic Views -============= - -OK, there aren't really generic views. Already the first implementation we -want to look at is a specic one: It is based on Zope Page Templates and -uses the classic CMF/Zope 3 approach: The template belonging to a view -calls a `main` macro and fills a slot there. But at least the template -implementation is decoupled from the view, so we are able to put a lot of -generic functionality into the view. - -In order to make a ZPT work we need a Zope-compatible request, so we use -the standard Zope 3 TestRequest. - - >>> from zope.publisher.browser import TestRequest - - >>> from cybertools.web.view import View - >>> view = View(None, TestRequest()) - >>> view.render() - u'< html...>............' - diff --git a/web/__init__.py b/web/__init__.py deleted file mode 100644 index 38314f3..0000000 --- a/web/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -""" -$Id$ -""" diff --git a/web/configure.zcml b/web/configure.zcml deleted file mode 100644 index dd31ae9..0000000 --- a/web/configure.zcml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - diff --git a/web/template.py b/web/template.py deleted file mode 100644 index dfdb0a1..0000000 --- a/web/template.py +++ /dev/null @@ -1,39 +0,0 @@ -# -# Copyright (c) 2006 Helmut Merz helmutm@cy55.de -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# - -""" -Generic template base class. - -$Id$ -""" - -from zope.app.traversing.adapters import DefaultTraversable -from zope import component - - -class Template(object): - - def __init__(self, view): - self.view = view - self.context = view.context - self.request = view.request - - def render(self, *args, **kw): - return u'' - -component.provideAdapter(DefaultTraversable, (Template,)) diff --git a/web/tests.py b/web/tests.py deleted file mode 100755 index 9b79252..0000000 --- a/web/tests.py +++ /dev/null @@ -1,30 +0,0 @@ -#! /usr/bin/python - -""" -Tests for the 'cybertools.index' package. - -$Id$ -""" - -import unittest, doctest -from zope.testing.doctestunit import DocFileSuite - -from cybertools.web import view - - -class Test(unittest.TestCase): - "Basic tests for the index package." - - def testBasicStuff(self): - pass - - -def test_suite(): - flags = doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS - return unittest.TestSuite(( - DocFileSuite('README.txt', optionflags=flags), - unittest.makeSuite(Test), - )) - -if __name__ == '__main__': - unittest.main(defaultTest='test_suite') diff --git a/web/view.py b/web/view.py deleted file mode 100644 index e6f626a..0000000 --- a/web/view.py +++ /dev/null @@ -1,43 +0,0 @@ -# -# Copyright (c) 2006 Helmut Merz helmutm@cy55.de -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# - -""" -Generic view base class. - -$Id$ -""" - -from zope.cachedescriptors.property import Lazy -from cybertools.web.zpt.template import Template - - -class View(object): - - templateFactory = Template - - def __init__(self, context, request): - self.context = context - self.request = request - - @Lazy - def template(self): - return self.templateFactory(self) - - def render(self, *args, **kw): - return self.template.render(*args, **kw) - diff --git a/web/zpt/__init__.py b/web/zpt/__init__.py deleted file mode 100644 index 38314f3..0000000 --- a/web/zpt/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -""" -$Id$ -""" diff --git a/web/zpt/configure.zcml b/web/zpt/configure.zcml deleted file mode 100644 index c072812..0000000 --- a/web/zpt/configure.zcml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - diff --git a/web/zpt/content.pt b/web/zpt/content.pt deleted file mode 100644 index cfdc7c3..0000000 --- a/web/zpt/content.pt +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - -
- This is the body -
-
- - - - diff --git a/web/zpt/main.pt b/web/zpt/main.pt deleted file mode 100644 index 4b56ac7..0000000 --- a/web/zpt/main.pt +++ /dev/null @@ -1,54 +0,0 @@ - - - - - - Powered by Zope 3 - - - - - - - - - - -
-
- -
-
- - - -
- - - - Here comes the body - -
- -
- -
- - - - - - -
- diff --git a/web/zpt/template.py b/web/zpt/template.py deleted file mode 100644 index ac0d016..0000000 --- a/web/zpt/template.py +++ /dev/null @@ -1,51 +0,0 @@ -# -# Copyright (c) 2006 Helmut Merz helmutm@cy55.de -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# - -""" -ZPT-based template base class. - -$Id$ -""" - -from zope.app.pagetemplate import ViewPageTemplateFile -from zope.cachedescriptors.property import Lazy -from cybertools.web import template - - -class Template(template.Template): - - zpt = ViewPageTemplateFile('content.pt') - - macroTemplate = ViewPageTemplateFile('main.pt') - - skin = None - - @Lazy - def main_macro(self): - return self.macroTemplate.macros['page'] - - @Lazy - def resourceBase(self): - skinSetter = self.skin and ('/++skin++' + self.skin.__name__) or '' - # TODO: put '/@@' etc after path to site instead of directly after URL0 - return self.request.URL[0] + skinSetter + '/@@/' - - def render(self, *args, **kw): - kw['template'] = self - return self.zpt(*args, **kw) -