[Product-Developers] Smartypants
Shane Graber
sgraber at gmail.com
Tue Jan 19 01:35:44 UTC 2010
I'm working on a customization to 'document_view.pt' that will pass the
standard 'text/getText' through typogrify.py[1] and smartypants.py[2] to
'prettify' the body text of Pages.
[1]
http://typogrify.googlecode.com/svn/trunk/typogrify/templatetags/typogrify.py
(with the django imports and register commented out)
[2] http://web.chad.org/projects/smartypants.py/smartypants.py-1.5_1.6
I'm working on Plone 3.1.7 and have the following change in:
Products/AAOLMViews/skins/aaolm_views/document_view.pt:
<!-- this replaces <metal:field use-macro="python:here.widget('text',
mode='view')">Body text</metal:field> -->
<div tal:content="structure python: context.typogrify_text(ttext=text)">
Typogrified Text
</div>
(Note: 'text' is defined at the top of the page template as 'text
here/getText')
----
In Products/AAOLMViews/skins/aaolm_views/typogrify_text.py:
## Script (Python) "typogrify_text"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=ttext=None
##title=Returns text that has been run through smartypants and typogrify
markup enhancers
from Products.AAOLMViews.typogrify import typogrify
return typogrify(ttext)
----
I have typogrify.py and smartypants.py living here:
Products/AAOLMViews/smartypants.py
Products/AAOLMViews/typogrify.py
----
I've also declared security adjustments for re, typogrify.py, and
smartypants.py in __init__.py:
Products.AAOLMViews/__init__.py:
# next three lines are for importing security routines to allow use
from AccessControl import allow_class, allow_type
from AccessControl import ModuleSecurityInfo
# allow security clearance
ModuleSecurityInfo('re').declarePublic('compile', 'findall',
'match', 'search', 'split', 'sub', 'subn', 'error',
'I', 'L', 'M', 'S', 'X')
import re
import typogrify
import smartypants
allow_type(type(re.compile('')))
allow_type(type(re.match('x','x')))
allow_type(type(re.sub('', '', '')))
allow_class(typogrify)
allow_class(smartypants)
----
Based on what I see, it should be working but I'm getting a traceback that I
can't seem to debug. Any help would be appreciated. Thanks!:
Traceback (innermost last):
Module ZPublisher.Publish, line 119, in publish
Module ZPublisher.mapply, line 88, in mapply
Module ZPublisher.Publish, line 42, in call_object
Module Shared.DC.Scripts.Bindings, line 313, in __call__
Module Shared.DC.Scripts.Bindings, line 350, in _bindAndExec
Module Products.CMFCore.FSPageTemplate, line 216, in _exec
Module Products.CMFCore.FSPageTemplate, line 155, in pt_render
Module Products.Gloworm, line 28, in pt_render
Module zope.pagetemplate.pagetemplate, line 117, in pt_render
Module zope.tal.talinterpreter, line 271, in __call__
Module zope.tal.talinterpreter, line 346, in interpret
Module zope.tal.talinterpreter, line 891, in do_useMacro
Module zope.tal.talinterpreter, line 346, in interpret
Module zope.tal.talinterpreter, line 536, in do_optTag_tal
Module zope.tal.talinterpreter, line 521, in do_optTag
Module zope.tal.talinterpreter, line 516, in no_tag
Module zope.tal.talinterpreter, line 346, in interpret
Module zope.tal.talinterpreter, line 957, in do_defineSlot
Module zope.tal.talinterpreter, line 346, in interpret
Module zope.tal.talinterpreter, line 536, in do_optTag_tal
Module zope.tal.talinterpreter, line 521, in do_optTag
Module zope.tal.talinterpreter, line 516, in no_tag
Module zope.tal.talinterpreter, line 346, in interpret
Module zope.tal.talinterpreter, line 861, in do_defineMacro
Module zope.tal.talinterpreter, line 346, in interpret
Module zope.tal.talinterpreter, line 957, in do_defineSlot
Module zope.tal.talinterpreter, line 346, in interpret
Module zope.tal.talinterpreter, line 536, in do_optTag_tal
Module zope.tal.talinterpreter, line 521, in do_optTag
Module zope.tal.talinterpreter, line 516, in no_tag
Module zope.tal.talinterpreter, line 346, in interpret
Module zope.tal.talinterpreter, line 536, in do_optTag_tal
Module zope.tal.talinterpreter, line 525, in do_optTag
Module zope.tal.talinterpreter, line 346, in interpret
Module zope.tal.talinterpreter, line 949, in do_defineSlot
Module zope.tal.talinterpreter, line 346, in interpret
Module zope.tal.talinterpreter, line 536, in do_optTag_tal
Module zope.tal.talinterpreter, line 521, in do_optTag
Module zope.tal.talinterpreter, line 516, in no_tag
Module zope.tal.talinterpreter, line 346, in interpret
Module zope.tal.talinterpreter, line 861, in do_defineMacro
Module zope.tal.talinterpreter, line 346, in interpret
Module zope.tal.talinterpreter, line 536, in do_optTag_tal
Module zope.tal.talinterpreter, line 521, in do_optTag
Module zope.tal.talinterpreter, line 516, in no_tag
Module zope.tal.talinterpreter, line 346, in interpret
Module zope.tal.talinterpreter, line 745, in do_insertStructure_tal
Module Products.PageTemplates.Expressions, line 221, in evaluateStructure
Module zope.tales.tales, line 696, in evaluate
- URL:
file:c:\projects\plone317\src\products.aaolmviews\Products\AAOLMViews\
skins\aaolm_views\document_view.pt
- Line 57, Column 8
- Expression: <PythonExpr context.typogrify_text(ttext=text)>
- Names:
{'container': <PloneSite at /advancedaquarist>,
'context': <ATDocument at /advancedaquarist/2008/aaeditorial>,
'default': <object object at 0x00A6C528>,
'here': <ATDocument at /advancedaquarist/2008/aaeditorial>,
'loop': {},
'nothing': None,
'options': {'args': ()},
'repeat': <Products.PageTemplates.Expressions.SafeMapping object at
0x083
1DE68>,
'request': <HTTPRequest, URL=
http://localhost:8080/advancedaquarist/2008/
aaeditorial/document_view>,
'root': <Application at >,
'template': <FSPageTemplate at /advancedaquarist/document_view used
for /
advancedaquarist/2008/aaeditorial>,
'traverse_subpath': [],
'user': <PropertiedUser 'admin'>}
Module Products.PageTemplates.ZRPythonExpr, line 49, in __call__
- __traceback_info__: context.typogrify_text(ttext=text)
Module PythonExpr, line 1, in <expression>
Module Products.CMFCore.FSPythonScript, line 140, in __call__
Module Shared.DC.Scripts.Bindings, line 313, in __call__
Module Shared.DC.Scripts.Bindings, line 350, in _bindAndExec
Module Products.CMFCore.FSPythonScript, line 196, in _exec
TypeError: typogrify_text() takes no arguments (1 given)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.plone.org/pipermail/plone-product-developers/attachments/20100118/f668e16d/attachment.html>
More information about the Product-Developers
mailing list