Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
6782b68b
Commit
6782b68b
authored
Jun 13, 2010
by
Hanno Schlichting
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make the App and reStructuredText dependencies in DocumentTemplate optional
parent
7a14524a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
24 deletions
+30
-24
AC-vs-DTML-TODO.txt
AC-vs-DTML-TODO.txt
+0
-8
src/DocumentTemplate/DT_Var.py
src/DocumentTemplate/DT_Var.py
+30
-16
No files found.
AC-vs-DTML-TODO.txt
View file @
6782b68b
...
@@ -46,11 +46,3 @@ DocumentTemplate
...
@@ -46,11 +46,3 @@ DocumentTemplate
* Missing
* Missing
* RestrictedPython
* RestrictedPython
* zExceptions
* zExceptions
- Remaining outside imports:
* App (getConfiguration().structured_text_header_level)
* reStructuredText (HTML) - Both of these deal with format support and
configuration via zope.conf. The calls are localized to one function each.
Add an optional dependency on Zope2? Configure if it is available,
otherwise use some default?
src/DocumentTemplate/DT_Var.py
View file @
6782b68b
...
@@ -148,22 +148,23 @@ Evaluating expressions without rendering results
...
@@ -148,22 +148,23 @@ Evaluating expressions without rendering results
A 'call' tag is provided for evaluating named objects or expressions
A 'call' tag is provided for evaluating named objects or expressions
without rendering the result.
without rendering the result.
$Id$
"""
"""
import
string
,
re
,
sys
import
logging
import
re
import
string
import
sys
from
urllib
import
quote
,
quote_plus
,
unquote
,
unquote_plus
from
urllib
import
quote
,
quote_plus
,
unquote
,
unquote_plus
from
Acquisition
import
aq_base
from
AccessControl.tainted
import
TaintedString
from
zope.structuredtext.document
import
DocumentWithImages
# for import by other modules, dont remove!
# for import by other modules, dont remove!
from
DocumentTemplate.html_quote
import
html_quote
from
DocumentTemplate.html_quote
import
html_quote
from
DocumentTemplate.DT_Util
import
parse_params
,
name_param
,
str
,
ustr
from
DocumentTemplate.DT_Util
import
parse_params
,
name_param
,
str
,
ustr
from
Acquisition
import
aq_base
logger
=
logging
.
getLogger
(
'DocumentTemplate'
)
from
AccessControl.tainted
import
TaintedString
from
zope.structuredtext.html
import
HTML
from
zope.structuredtext.document
import
DocumentWithImages
from
App.config
import
getConfiguration
class
Var
:
class
Var
:
...
@@ -399,30 +400,43 @@ def len_format(v, name='(Unknown name)', md={}):
...
@@ -399,30 +400,43 @@ def len_format(v, name='(Unknown name)', md={}):
def
len_comma
(
v
,
name
=
'(Unknown name)'
,
md
=
{}):
def
len_comma
(
v
,
name
=
'(Unknown name)'
,
md
=
{}):
return
thousands_commas
(
str
(
len
(
v
)))
return
thousands_commas
(
str
(
len
(
v
)))
def
restructured_text
(
v
,
name
=
'(Unknown name)'
,
md
=
{}):
from
reStructuredText
import
HTML
if
isinstance
(
v
,
str
):
def
restructured_text
(
v
,
name
=
'(Unknown name)'
,
md
=
{}):
try
:
from
reStructuredText
import
HTML
except
ImportError
:
logger
.
info
(
'The reStructuredText package is not available, therefor '
'the DT_Var.restructured_text function returns None.'
)
return
None
if
isinstance
(
v
,
str
):
txt
=
v
txt
=
v
elif
aq_base
(
v
).
meta_type
in
[
'DTML Document'
,
'DTML Method'
]:
elif
aq_base
(
v
).
meta_type
in
[
'DTML Document'
,
'DTML Method'
]:
txt
=
aq_base
(
v
).
read_raw
()
txt
=
aq_base
(
v
).
read_raw
()
else
:
else
:
txt
=
str
(
v
)
txt
=
str
(
v
)
return
HTML
(
txt
)
return
HTML
(
txt
)
def
structured_text
(
v
,
name
=
'(Unknown name)'
,
md
=
{}):
def
structured_text
(
v
,
name
=
'(Unknown name)'
,
md
=
{}):
from
zope.structuredtext.html
import
HTML
if
isinstance
(
v
,
str
):
if
isinstance
(
v
,
str
):
txt
=
v
txt
=
v
elif
aq_base
(
v
).
meta_type
in
[
'DTML Document'
,
'DTML Method'
]:
elif
aq_base
(
v
).
meta_type
in
[
'DTML Document'
,
'DTML Method'
]:
txt
=
aq_base
(
v
).
read_raw
()
txt
=
aq_base
(
v
).
read_raw
()
else
:
else
:
txt
=
str
(
v
)
txt
=
str
(
v
)
level
=
getConfiguration
().
structured_text_header_level
level
=
3
try
:
from
App.config
import
getConfiguration
except
ImportError
:
pass
else
:
level
=
getConfiguration
().
structured_text_header_level
doc
=
DocumentWithImages
()(
txt
)
doc
=
DocumentWithImages
()(
txt
)
return
HTML
()(
doc
,
level
,
header
=
False
)
return
HTML
()(
doc
,
level
,
header
=
False
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment