zope.ptresource-3.9.0/ 0000755 0001750 0001750 00000000000 11245515177 013076 5 ustar nyo nyo zope.ptresource-3.9.0/setup.cfg 0000644 0001750 0001750 00000000073 11245515177 014717 0 ustar nyo nyo [egg_info]
tag_build =
tag_date = 0
tag_svn_revision = 0
zope.ptresource-3.9.0/PKG-INFO 0000644 0001750 0001750 00000003727 11245515177 014204 0 ustar nyo nyo Metadata-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/ 0000755 0001750 0001750 00000000000 11245515177 013665 5 ustar nyo nyo zope.ptresource-3.9.0/src/zope.ptresource.egg-info/ 0000755 0001750 0001750 00000000000 11245515177 020526 5 ustar nyo nyo zope.ptresource-3.9.0/src/zope.ptresource.egg-info/PKG-INFO 0000644 0001750 0001750 00000003727 11245515175 021632 0 ustar nyo nyo Metadata-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.txt 0000644 0001750 0001750 00000000005 11245515175 025052 0 ustar nyo nyo zope
zope.ptresource-3.9.0/src/zope.ptresource.egg-info/SOURCES.txt 0000644 0001750 0001750 00000001004 11245515175 022403 0 ustar nyo nyo CHANGES.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.py zope.ptresource-3.9.0/src/zope.ptresource.egg-info/not-zip-safe 0000644 0001750 0001750 00000000001 11245515167 022753 0 ustar nyo nyo
zope.ptresource-3.9.0/src/zope.ptresource.egg-info/top_level.txt 0000644 0001750 0001750 00000000005 11245515175 023251 0 ustar nyo nyo zope
zope.ptresource-3.9.0/src/zope.ptresource.egg-info/requires.txt 0000644 0001750 0001750 00000000203 11245515175 023117 0 ustar nyo nyo setuptools
zope.browserresource
zope.interface
zope.pagetemplate
zope.publisher
zope.security[untrustedpython]
[test]
zope.testing zope.ptresource-3.9.0/src/zope.ptresource.egg-info/dependency_links.txt 0000644 0001750 0001750 00000000001 11245515175 024572 0 ustar nyo nyo
zope.ptresource-3.9.0/src/zope/ 0000755 0001750 0001750 00000000000 11245515177 014642 5 ustar nyo nyo zope.ptresource-3.9.0/src/zope/ptresource/ 0000755 0001750 0001750 00000000000 11245515177 017035 5 ustar nyo nyo zope.ptresource-3.9.0/src/zope/ptresource/ptresource.py 0000644 0001750 0001750 00000006346 11245515157 021611 0 ustar nyo nyo ##############################################################################
#
# 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.zcml 0000644 0001750 0001750 00000001375 11245515157 021711 0 ustar nyo nyo
zope.ptresource-3.9.0/src/zope/ptresource/tests.py 0000644 0001750 0001750 00000005734 11245515157 020560 0 ustar nyo nyo ##############################################################################
#
# 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__.py 0000644 0001750 0001750 00000000000 11245515157 021132 0 ustar nyo nyo zope.ptresource-3.9.0/src/zope/__init__.py 0000644 0001750 0001750 00000000070 11245515157 016746 0 ustar nyo nyo __import__('pkg_resources').declare_namespace(__name__)
zope.ptresource-3.9.0/bootstrap.py 0000644 0001750 0001750 00000003373 11245515157 015471 0 ustar nyo nyo ##############################################################################
#
# 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.py 0000644 0001750 0001750 00000004074 11245515157 014613 0 ustar nyo nyo ##############################################################################
#
# 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.txt 0000644 0001750 0001750 00000000775 11245515157 014603 0 ustar nyo nyo ========
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.txt 0000644 0001750 0001750 00000001157 11245515157 014711 0 ustar nyo nyo =======
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.cfg 0000644 0001750 0001750 00000000614 11245515157 015405 0 ustar nyo nyo [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')