zope.ptresource-3.9.0/0000755000175000017500000000000011245515177013076 5ustar nyonyozope.ptresource-3.9.0/setup.cfg0000644000175000017500000000007311245515177014717 0ustar nyonyo[egg_info] tag_build = tag_date = 0 tag_svn_revision = 0 zope.ptresource-3.9.0/PKG-INFO0000644000175000017500000000372711245515177014204 0ustar nyonyoMetadata-Version: 1.0 Name: zope.ptresource Version: 3.9.0 Summary: Page template resource plugin for zope.browserresource Home-page: http://pypi.python.org/pypi/zope.ptresource/ Author: Zope Corporation and Contributors Author-email: zope-dev@zope.org License: UNKNOWN Description: ======== Overview ======== *This package is at present not reusable without depending on a large chunk of the Zope Toolkit and its assumptions. It is maintained by the* `Zope Toolkit project `_. This package provides a "page template" resource class, a resource which content is processed with Zope Page Templates engine before returning to client. The resource factory class is registered for "pt", "zpt" and "html" file extensions in package's ``configure.zcml`` file. ======= CHANGES ======= 3.9.0 (2009-08-27) ================== Initial release. This package was splitted off zope.app.publisher as a part of refactoring process. It's now a plugin for another package that was refactored from zope.app.publisher - zope.browserresource. See its documentation for more details. Other changes: * Don't render PageTemplateResource when called as the IResource interface requires that __call__ method should return an absolute URL. When accessed by browser, it still will be rendered, because "browserDefault" method now returns a callable that will render the template to browser. Platform: UNKNOWN Classifier: Environment :: Web Environment Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: Zope Public License Classifier: Programming Language :: Python Classifier: Operating System :: OS Independent Classifier: Topic :: Internet :: WWW/HTTP Classifier: Framework :: Zope3 zope.ptresource-3.9.0/src/0000755000175000017500000000000011245515177013665 5ustar nyonyozope.ptresource-3.9.0/src/zope.ptresource.egg-info/0000755000175000017500000000000011245515177020526 5ustar nyonyozope.ptresource-3.9.0/src/zope.ptresource.egg-info/PKG-INFO0000644000175000017500000000372711245515175021632 0ustar nyonyoMetadata-Version: 1.0 Name: zope.ptresource Version: 3.9.0 Summary: Page template resource plugin for zope.browserresource Home-page: http://pypi.python.org/pypi/zope.ptresource/ Author: Zope Corporation and Contributors Author-email: zope-dev@zope.org License: UNKNOWN Description: ======== Overview ======== *This package is at present not reusable without depending on a large chunk of the Zope Toolkit and its assumptions. It is maintained by the* `Zope Toolkit project `_. This package provides a "page template" resource class, a resource which content is processed with Zope Page Templates engine before returning to client. The resource factory class is registered for "pt", "zpt" and "html" file extensions in package's ``configure.zcml`` file. ======= CHANGES ======= 3.9.0 (2009-08-27) ================== Initial release. This package was splitted off zope.app.publisher as a part of refactoring process. It's now a plugin for another package that was refactored from zope.app.publisher - zope.browserresource. See its documentation for more details. Other changes: * Don't render PageTemplateResource when called as the IResource interface requires that __call__ method should return an absolute URL. When accessed by browser, it still will be rendered, because "browserDefault" method now returns a callable that will render the template to browser. Platform: UNKNOWN Classifier: Environment :: Web Environment Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: Zope Public License Classifier: Programming Language :: Python Classifier: Operating System :: OS Independent Classifier: Topic :: Internet :: WWW/HTTP Classifier: Framework :: Zope3 zope.ptresource-3.9.0/src/zope.ptresource.egg-info/namespace_packages.txt0000644000175000017500000000000511245515175025052 0ustar nyonyozope zope.ptresource-3.9.0/src/zope.ptresource.egg-info/SOURCES.txt0000644000175000017500000000100411245515175022403 0ustar nyonyoCHANGES.txt README.txt bootstrap.py buildout.cfg setup.py src/zope/__init__.py src/zope.ptresource.egg-info/PKG-INFO src/zope.ptresource.egg-info/SOURCES.txt src/zope.ptresource.egg-info/dependency_links.txt src/zope.ptresource.egg-info/namespace_packages.txt src/zope.ptresource.egg-info/not-zip-safe src/zope.ptresource.egg-info/requires.txt src/zope.ptresource.egg-info/top_level.txt src/zope/ptresource/__init__.py src/zope/ptresource/configure.zcml src/zope/ptresource/ptresource.py src/zope/ptresource/tests.pyzope.ptresource-3.9.0/src/zope.ptresource.egg-info/not-zip-safe0000644000175000017500000000000111245515167022753 0ustar nyonyo zope.ptresource-3.9.0/src/zope.ptresource.egg-info/top_level.txt0000644000175000017500000000000511245515175023251 0ustar nyonyozope zope.ptresource-3.9.0/src/zope.ptresource.egg-info/requires.txt0000644000175000017500000000020311245515175023117 0ustar nyonyosetuptools zope.browserresource zope.interface zope.pagetemplate zope.publisher zope.security[untrustedpython] [test] zope.testingzope.ptresource-3.9.0/src/zope.ptresource.egg-info/dependency_links.txt0000644000175000017500000000000111245515175024572 0ustar nyonyo zope.ptresource-3.9.0/src/zope/0000755000175000017500000000000011245515177014642 5ustar nyonyozope.ptresource-3.9.0/src/zope/ptresource/0000755000175000017500000000000011245515177017035 5ustar nyonyozope.ptresource-3.9.0/src/zope/ptresource/ptresource.py0000644000175000017500000000634611245515157021611 0ustar nyonyo############################################################################## # # Copyright (c) 2001, 2002 Zope Corporation and Contributors. # All Rights Reserved. # # This software is subject to the provisions of the Zope Public License, # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. # ############################################################################## """Page Template Resource $Id: ptresource.py 103139 2009-08-24 11:58:22Z nadako $ """ from zope.interface import implements, classProvides from zope.pagetemplate.engine import TrustedAppPT from zope.pagetemplate.pagetemplatefile import PageTemplateFile from zope.publisher.browser import BrowserView from zope.publisher.interfaces import NotFound from zope.publisher.interfaces.browser import IBrowserPublisher from zope.browserresource.resource import Resource from zope.browserresource.interfaces import IResourceFactory from zope.browserresource.interfaces import IResourceFactoryFactory class PageTemplate(TrustedAppPT, PageTemplateFile): """ Resource that is a page template """ def __init__(self, filename, _prefix=None, content_type=None): _prefix = self.get_path_from_prefix(_prefix) super(PageTemplate, self).__init__(filename, _prefix) if content_type is not None: self.content_type = content_type def pt_getContext(self, request, **kw): namespace = super(PageTemplate, self).pt_getContext(**kw) namespace['context'] = None namespace['request'] = request return namespace def __call__(self, request, **keywords): namespace = self.pt_getContext( request=request, options=keywords ) return self.pt_render(namespace) class PageTemplateResource(BrowserView, Resource): implements(IBrowserPublisher) def publishTraverse(self, request, name): '''See interface IBrowserPublisher''' raise NotFound(None, name) def browserDefault(self, request): '''See interface IBrowserPublisher''' return getattr(self, request.method), () def HEAD(self): pt = self.context response = self.request.response if not response.getHeader("Content-Type"): response.setHeader("Content-Type", pt.content_type) return '' def GET(self): pt = self.context response = self.request.response if not response.getHeader("Content-Type"): response.setHeader("Content-Type", pt.content_type) return pt(self.request) class PageTemplateResourceFactory(object): implements(IResourceFactory) classProvides(IResourceFactoryFactory) def __init__(self, path, checker, name): self.__pt = PageTemplate(path) self.__checker = checker self.__name = name def __call__(self, request): resource = PageTemplateResource(self.__pt, request) resource.__Security_checker__ = self.__checker resource.__name__ = self.__name return resource zope.ptresource-3.9.0/src/zope/ptresource/configure.zcml0000644000175000017500000000137511245515157021711 0ustar nyonyo zope.ptresource-3.9.0/src/zope/ptresource/tests.py0000644000175000017500000000573411245515157020560 0ustar nyonyo############################################################################## # # Copyright (c) 2001, 2002 Zope Corporation and Contributors. # All Rights Reserved. # # This software is subject to the provisions of the Zope Public License, # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. # ############################################################################## """Page Template based Resources Test $Id: tests.py 103139 2009-08-24 11:58:22Z nadako $ """ import os import tempfile import unittest from zope.component import provideAdapter from zope.publisher.browser import TestRequest from zope.publisher.interfaces import NotFound from zope.security.checker import NamesChecker from zope.testing import cleanup from zope.traversing.adapters import DefaultTraversable from zope.traversing.interfaces import ITraversable from zope.ptresource.ptresource import PageTemplateResourceFactory checker = NamesChecker(('__call__', 'request', 'publishTraverse')) class Test(cleanup.CleanUp, unittest.TestCase): def setUp(self): super(Test, self).setUp() provideAdapter(DefaultTraversable, (None,), ITraversable) def createTestFile(self, contents): fd, path = tempfile.mkstemp() os.close(fd) open(path, 'w').write(contents) return path def testNoTraversal(self): path = self.createTestFile('

test

') request = TestRequest() factory = PageTemplateResourceFactory(path, checker, 'test.pt') resource = factory(request) self.assertRaises(NotFound, resource.publishTraverse, resource.request, ()) os.unlink(path) def testBrowserDefault(self): path = self.createTestFile( '') test_data = "Foobar" request = TestRequest(test_data=test_data) factory = PageTemplateResourceFactory(path, checker, 'testresource.pt') resource = factory(request) view, next = resource.browserDefault(request) self.assertEquals(view(), '%s' % test_data) self.assertEquals('text/html', request.response.getHeader('Content-Type')) self.assertEquals(next, ()) request = TestRequest(test_data=test_data, REQUEST_METHOD='HEAD') resource = factory(request) view, next = resource.browserDefault(request) self.assertEquals(view(), '') self.assertEquals('text/html', request.response.getHeader('Content-Type')) self.assertEquals(next, ()) os.unlink(path) def test_suite(): return unittest.makeSuite(Test) zope.ptresource-3.9.0/src/zope/ptresource/__init__.py0000644000175000017500000000000011245515157021132 0ustar nyonyozope.ptresource-3.9.0/src/zope/__init__.py0000644000175000017500000000007011245515157016746 0ustar nyonyo__import__('pkg_resources').declare_namespace(__name__) zope.ptresource-3.9.0/bootstrap.py0000644000175000017500000000337311245515157015471 0ustar nyonyo############################################################################## # # Copyright (c) 2006 Zope Corporation and Contributors. # All Rights Reserved. # # This software is subject to the provisions of the Zope Public License, # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. # ############################################################################## """Bootstrap a buildout-based project Simply run this script in a directory containing a buildout.cfg. The script accepts buildout command-line options, so you can use the -c option to specify an alternate configuration file. $Id: bootstrap.py 103117 2009-08-23 19:54:32Z nadako $ """ import os, shutil, sys, tempfile, urllib2 tmpeggs = tempfile.mkdtemp() ez = {} exec urllib2.urlopen('http://peak.telecommunity.com/dist/ez_setup.py' ).read() in ez ez['use_setuptools'](to_dir=tmpeggs, download_delay=0) import pkg_resources cmd = 'from setuptools.command.easy_install import main; main()' if sys.platform == 'win32': cmd = '"%s"' % cmd # work around spawn lamosity on windows ws = pkg_resources.working_set assert os.spawnle( os.P_WAIT, sys.executable, sys.executable, '-c', cmd, '-mqNxd', tmpeggs, 'zc.buildout', dict(os.environ, PYTHONPATH= ws.find(pkg_resources.Requirement.parse('setuptools')).location ), ) == 0 ws.add_entry(tmpeggs) ws.require('zc.buildout') import zc.buildout.buildout zc.buildout.buildout.main(sys.argv[1:] + ['bootstrap']) shutil.rmtree(tmpeggs) zope.ptresource-3.9.0/setup.py0000644000175000017500000000407411245515157014613 0ustar nyonyo############################################################################## # # Copyright (c) 2007 Zope Corporation and Contributors. # All Rights Reserved. # # This software is subject to the provisions of the Zope Public License, # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. # ############################################################################## """zope.ptresource setup """ from setuptools import setup, find_packages, Extension long_description = (open('README.txt').read() + '\n\n' + open('CHANGES.txt').read()) setup(name='zope.ptresource', version = '3.9.0', url='http://pypi.python.org/pypi/zope.ptresource/', author='Zope Corporation and Contributors', author_email='zope-dev@zope.org', classifiers = ['Environment :: Web Environment', 'Intended Audience :: Developers', 'License :: OSI Approved :: Zope Public License', 'Programming Language :: Python', 'Operating System :: OS Independent', 'Topic :: Internet :: WWW/HTTP', 'Framework :: Zope3', ], description='Page template resource plugin for zope.browserresource', long_description=long_description, packages=find_packages('src'), package_dir={'': 'src'}, namespace_packages=['zope'], include_package_data=True, install_requires=['setuptools', 'zope.browserresource', 'zope.interface', 'zope.pagetemplate', 'zope.publisher', 'zope.security[untrustedpython]', ], extras_require={ 'test': ['zope.testing'], }, zip_safe = False, ) zope.ptresource-3.9.0/README.txt0000644000175000017500000000077511245515157014603 0ustar nyonyo======== Overview ======== *This package is at present not reusable without depending on a large chunk of the Zope Toolkit and its assumptions. It is maintained by the* `Zope Toolkit project `_. This package provides a "page template" resource class, a resource which content is processed with Zope Page Templates engine before returning to client. The resource factory class is registered for "pt", "zpt" and "html" file extensions in package's ``configure.zcml`` file. zope.ptresource-3.9.0/CHANGES.txt0000644000175000017500000000115711245515157014711 0ustar nyonyo======= CHANGES ======= 3.9.0 (2009-08-27) ================== Initial release. This package was splitted off zope.app.publisher as a part of refactoring process. It's now a plugin for another package that was refactored from zope.app.publisher - zope.browserresource. See its documentation for more details. Other changes: * Don't render PageTemplateResource when called as the IResource interface requires that __call__ method should return an absolute URL. When accessed by browser, it still will be rendered, because "browserDefault" method now returns a callable that will render the template to browser. zope.ptresource-3.9.0/buildout.cfg0000644000175000017500000000061411245515157015405 0ustar nyonyo[buildout] develop = . parts = test coverage-test coverage-report [test] recipe = zc.recipe.testrunner eggs = zope.ptresource [test] [coverage-test] recipe = zc.recipe.testrunner eggs = zope.ptresource [test] defaults = ['--coverage', '../../coverage'] [coverage-report] recipe = zc.recipe.egg eggs = z3c.coverage scripts = coverage=coverage-report arguments = ('coverage', 'coverage/report')