This repository has been archived by the owner on Feb 12, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 9c66fac
Showing
7 changed files
with
142 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Malthe Borch <mborch@gmail.com> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
Overview | ||
======== | ||
|
||
The cmf.pt package allows using the Chameleon template engine with the | ||
Zope 2 CMF. | ||
|
||
Usage | ||
----- | ||
|
||
To enable Chameleon, simply include the ZCML configuration:: | ||
|
||
<include package="five.pt" /> | ||
<include package="cmf.pt" /> | ||
|
||
For general information about Chameleon, see | ||
http://chameleon.repoze.org/. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from setuptools import setup, find_packages | ||
|
||
version = '0.1' | ||
|
||
setup(name='cmf.pt', | ||
version=version, | ||
description="Bridge to use Chameleon with Zope 2 and CMF.", | ||
long_description=open("README.txt").read() + open("CHANGES.txt").read(), | ||
classifiers=[ | ||
"Framework :: Zope2", | ||
"Programming Language :: Python", | ||
"Topic :: Text Processing :: Markup :: HTML", | ||
"Topic :: Text Processing :: Markup :: XML", | ||
"Topic :: Software Development :: Libraries :: Python Modules", | ||
], | ||
keywords='', | ||
author='Malthe Borch and the Zope community', | ||
author_email='zope-dev@zope.org', | ||
url='', | ||
license='ZPL', | ||
namespace_packages=['cmf'], | ||
packages = find_packages('src'), | ||
package_dir = {'':'src'}, | ||
include_package_data=True, | ||
zip_safe=False, | ||
install_requires=[ | ||
'setuptools', | ||
'z3c.pt', | ||
'five.pt', | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages | ||
try: | ||
__import__('pkg_resources').declare_namespace(__name__) | ||
except ImportError: | ||
from pkgutil import extend_path | ||
__path__ = extend_path(__path__, __name__) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import Globals | ||
|
||
from Products.CMFCore.FSObject import FSObject | ||
from Products.CMFCore import DirectoryView | ||
from Products.CMFCore import permissions | ||
|
||
from Products.CMFFormController.BaseControllerPageTemplate import \ | ||
BaseControllerPageTemplate as BaseCPT | ||
from Products.CMFFormController.FSControllerBase import FSControllerBase | ||
|
||
from Shared.DC.Scripts.Script import Script | ||
from AccessControl import ClassSecurityInfo | ||
from RestrictedPython import Utilities | ||
|
||
from five.pt.pagetemplate import BaseTemplateFile | ||
|
||
class FSPageTemplate(BaseTemplateFile, FSObject, Script): | ||
meta_type = 'Filesystem Page Template' | ||
|
||
security = ClassSecurityInfo() | ||
security.declareObjectProtected(permissions.View) | ||
|
||
_default_bindings = {'name_subpath': 'traverse_subpath'} | ||
|
||
utility_builtins = Utilities.utility_builtins | ||
|
||
def __init__(self, id, filepath, fullname=None, properties=None): | ||
FSObject.__init__(self, id, filepath, fullname, properties) | ||
self.ZBindings_edit(self._default_bindings) | ||
|
||
# instantiate page template | ||
BaseTemplateFile.__init__(self, filepath) | ||
|
||
def _readFile(self, reparse): | ||
# templates are lazy | ||
if reparse: | ||
self.read() | ||
|
||
def __call__(self, *args, **kwargs): | ||
kwargs['args'] = args | ||
return BaseTemplateFile.__call__(self, self, **kwargs) | ||
|
||
@property | ||
def func_code(self): | ||
return self.render.func_code | ||
|
||
class FSControllerPageTemplate(FSPageTemplate, FSControllerBase, BaseCPT): | ||
def __init__(self, id, filepath, fullname=None, properties=None): | ||
FSPageTemplate.__init__(self, id, filepath, fullname, properties) | ||
self.filepath = filepath | ||
|
||
self._read_action_metadata(self.getId(), filepath) | ||
self._read_validator_metadata(self.getId(), filepath) | ||
|
||
def _readFile(self, reparse): | ||
FSPageTemplate._readFile(self, reparse) | ||
self._readMetadata() | ||
|
||
def _updateFromFS(self): | ||
# workaround for Python 2.1 multiple inheritance lameness | ||
return self._baseUpdateFromFS() | ||
|
||
def _readMetadata(self): | ||
# workaround for Python 2.1 multiple inheritance lameness | ||
return self._baseReadMetadata() | ||
|
||
def __call__(self, *args, **kwargs): | ||
return self._call(FSPageTemplate.__call__, *args, **kwargs) | ||
|
||
Globals.InitializeClass(FSPageTemplate) | ||
Globals.InitializeClass(FSControllerPageTemplate) | ||
|
||
DirectoryView.registerFileExtension('pt', FSPageTemplate) | ||
DirectoryView.registerFileExtension('zpt', FSPageTemplate) | ||
DirectoryView.registerFileExtension('html', FSPageTemplate) | ||
DirectoryView.registerFileExtension('htm', FSPageTemplate) | ||
DirectoryView.registerFileExtension('cpt', FSControllerPageTemplate) | ||
|
||
DirectoryView.registerMetaType('Page Template', FSPageTemplate) | ||
DirectoryView.registerMetaType('Controller Page Template', FSControllerPageTemplate) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<configure xmlns="http://namespaces.zope.org/zope"> | ||
|
||
<include package="five.pt" /> | ||
<include package=".cmf" /> | ||
|
||
</configure> |