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
62cce377
Commit
62cce377
authored
Aug 11, 1998
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Made use (or non-use) of regex thread safe.
parent
699ed75c
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
26 deletions
+37
-26
lib/python/DocumentTemplate/DT_HTML.py
lib/python/DocumentTemplate/DT_HTML.py
+15
-10
lib/python/DocumentTemplate/DT_In.py
lib/python/DocumentTemplate/DT_In.py
+7
-4
lib/python/DocumentTemplate/DT_String.py
lib/python/DocumentTemplate/DT_String.py
+2
-2
lib/python/DocumentTemplate/DT_Var.py
lib/python/DocumentTemplate/DT_Var.py
+13
-10
No files found.
lib/python/DocumentTemplate/DT_HTML.py
View file @
62cce377
"""HTML formated DocumentTemplates
$Id: DT_HTML.py,v 1.
6 1998/04/02 17:37:35
jim Exp $"""
$Id: DT_HTML.py,v 1.
7 1998/08/11 19:32:38
jim Exp $"""
from
DT_String
import
String
,
FileMixin
import
DT_Doc
,
DT_String
,
regex
from
DT_Util
import
*
from
regsub
import
gsub
from
string
import
strip
,
find
from
string
import
strip
,
find
,
split
,
join
class
dtml_re_class
:
...
...
@@ -108,13 +108,13 @@ class HTML(DT_String.String):
def
quotedHTML
(
self
,
text
=
None
,
character_entities
=
(
(
regex
.
compile
(
'&'
),
'&'
),
(
regex
.
compile
(
"<"
),
'<'
),
(
regex
.
compile
(
">"
),
'>'
),
(
regex
.
compile
(
'"'
),
'"'
))):
#"
((
'&'
),
'&'
),
((
"<"
),
'<'
),
((
">"
),
'>'
),
((
'"'
),
'"'
))):
#"
if
text
is
None
:
text
=
self
.
read_raw
()
for
re
,
name
in
character_entities
:
text
=
gsub
(
re
,
name
,
text
)
if
find
(
text
,
re
)
>=
0
:
text
=
join
(
split
(
text
,
re
),
name
)
return
text
errQuote
=
quotedHTML
...
...
@@ -192,11 +192,13 @@ class HTMLFile(FileMixin, HTML):
manage_editDocument
=
manage
=
manage_editForm
def
manage_edit
(
self
,
data
,
PARENTS
=
[],
URL1
=
''
,
URL2
=
''
,
REQUEST
=
''
,
SUBMIT
=
''
,
crlf
=
regex
.
compile
(
'
\
r
\
n
\
|
\
n
\
r
'
)):
PARENTS
=
[],
URL1
=
''
,
URL2
=
''
,
REQUEST
=
''
,
SUBMIT
=
''
):
'edit a template'
if
SUBMIT
==
FactoryDefaultString
:
return
self
.
manage_default
(
REQUEST
)
data
=
gsub
(
crlf
,
'
\
n
'
,
data
)
if
find
(
data
,
'
\
r
'
):
data
=
join
(
split
(
data
,
'
\
r
\
n
'
),
'
\
n
\
r
'
)
data
=
join
(
split
(
data
,
'
\
n
\
r
'
),
'
\
n
'
)
if
self
.
edited_source
:
self
.
edited_source
=
data
self
.
cooked
=
self
.
cook
()
...
...
@@ -211,6 +213,9 @@ class HTMLFile(FileMixin, HTML):
##########################################################################
#
# $Log: DT_HTML.py,v $
# Revision 1.7 1998/08/11 19:32:38 jim
# Made use (or non-use) of regex thread safe.
#
# Revision 1.6 1998/04/02 17:37:35 jim
# Major redesign of block rendering. The code inside a block tag is
# compiled as a template but only the templates blocks are saved, and
...
...
lib/python/DocumentTemplate/DT_In.py
View file @
62cce377
...
...
@@ -296,7 +296,7 @@
'''
#'
__rcs_id__
=
'$Id: DT_In.py,v 1.2
4 1998/04/08 17:45:59
jim Exp $'
__rcs_id__
=
'$Id: DT_In.py,v 1.2
5 1998/08/11 19:34:48
jim Exp $'
############################################################################
# Copyright
...
...
@@ -350,11 +350,11 @@ __rcs_id__='$Id: DT_In.py,v 1.24 1998/04/08 17:45:59 jim Exp $'
# (540) 371-6909
#
############################################################################
__version__
=
'$Revision: 1.2
4
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.2
5
$'
[
11
:
-
2
]
from
DT_Util
import
*
from
string
import
find
,
atoi
,
join
import
regex
import
ts_
regex
from
regsub
import
gsub
from
DT_InSV
import
sequence_variables
,
opt
...
...
@@ -402,7 +402,7 @@ class InClass:
if
type
(
v
)
==
type
(
''
):
try
:
atoi
(
v
)
except
:
self
.
start_name_re
=
regex
.
compile
(
self
.
start_name_re
=
ts_
regex
.
compile
(
'&+'
+
join
(
map
(
lambda
c
:
"[%s]"
%
c
,
v
),
''
)
+
'=[0-9]+&+'
)
...
...
@@ -690,6 +690,9 @@ def int_param(params,md,name,default=0):
############################################################################
# $Log: DT_In.py,v $
# Revision 1.25 1998/08/11 19:34:48 jim
# Made use (or non-use) of regex thread safe.
#
# Revision 1.24 1998/04/08 17:45:59 jim
# Now check security of items, and new skip_unauthorized attr.
#
...
...
lib/python/DocumentTemplate/DT_String.py
View file @
62cce377
from
string
import
*
import
DT_Doc
,
DT_Var
,
DT_In
,
DT_If
,
regex
,
DT_Raise
,
DT_With
import
DT_Doc
,
DT_Var
,
DT_In
,
DT_If
,
regex
,
ts_regex
,
DT_Raise
,
DT_With
Var
=
DT_Var
.
Var
from
DT_Util
import
*
...
...
@@ -39,7 +39,7 @@ class String:
def
SubTemplate
(
self
,
name
):
return
String
(
''
,
__name__
=
name
)
def
tagre
(
self
):
return
regex
.
symcomp
(
return
ts_
regex
.
symcomp
(
'%('
# beginning
'
\
(<
n
ame>[a-zA-Z0-9_/.-]+
\
)
'
# tag name
'
\
(
'
...
...
lib/python/DocumentTemplate/DT_Var.py
View file @
62cce377
...
...
@@ -114,7 +114,7 @@ Evaluating expressions without rendering results
'''
# '
__rcs_id__
=
'$Id: DT_Var.py,v 1.1
4 1998/04/14 11:58:21
jim Exp $'
__rcs_id__
=
'$Id: DT_Var.py,v 1.1
5 1998/08/11 19:36:54
jim Exp $'
############################################################################
# Copyright
...
...
@@ -168,10 +168,10 @@ __rcs_id__='$Id: DT_Var.py,v 1.14 1998/04/14 11:58:21 jim Exp $'
# (540) 371-6909
#
############################################################################
__version__
=
'$Revision: 1.1
4
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.1
5
$'
[
11
:
-
2
]
from
DT_Util
import
*
import
ts_regex
from
string
import
find
,
split
,
join
class
Var
:
...
...
@@ -282,13 +282,13 @@ class Call:
def
html_quote
(
v
,
name
=
'(Unknown name)'
,
md
=
{},
character_entities
=
(
(
regex
.
compile
(
'&'
),
'&'
),
(
regex
.
compile
(
"<"
),
'<'
),
(
regex
.
compile
(
">"
),
'>'
),
(
regex
.
compile
(
'"'
),
'"'
))):
#"
((
'&'
),
'&'
),
((
"<"
),
'<'
),
((
">"
),
'>'
),
((
'"'
),
'"'
))):
#"
text
=
str
(
v
)
for
re
,
name
in
character_entities
:
text
=
gsub
(
re
,
name
,
text
)
if
find
(
text
,
re
)
>=
0
:
text
=
join
(
split
(
text
,
re
),
name
)
return
text
def
url_quote
(
v
,
name
=
'(Unknown name)'
,
md
=
{}):
...
...
@@ -296,7 +296,7 @@ def url_quote(v, name='(Unknown name)', md={}):
return
urllib
.
quote
(
str
(
v
))
def
newline_to_br
(
v
,
name
=
'(Unknown name)'
,
md
=
{},
nl
=
regex
.
compile
(
'
\
r
?
\
n
'
)):
nl
=
ts_
regex
.
compile
(
'
\
r
?
\
n
'
)):
return
gsub
(
nl
,
'<br>
\
n
'
,
str
(
v
))
def
whole_dollars
(
v
,
name
=
'(Unknown name)'
,
md
=
{}):
...
...
@@ -308,7 +308,7 @@ def dollars_and_cents(v, name='(Unknown name)', md={}):
except
:
return
''
def
thousands_commas
(
v
,
name
=
'(Unknown name)'
,
md
=
{},
thou
=
regex
.
compile
(
"
\
([
0
-9]
\
)
\
([0-9][0-9][0-9]
\
([,.]
\
|$
\
)
\
)"
)):
thou
=
ts_
regex
.
compile
(
"
\
([
0
-9]
\
)
\
([0-9][0-9][0-9]
\
([,.]
\
|$
\
)
\
)"
)):
v
=
str
(
v
)
while
thou
.
search
(
v
)
>=
0
:
v
=
sub
(
thou
,
"
\
\
1,
\
\
2"
,
v
)
...
...
@@ -370,6 +370,9 @@ modifiers=map(lambda f: (f.__name__, f), modifiers)
############################################################################
# $Log: DT_Var.py,v $
# Revision 1.15 1998/08/11 19:36:54 jim
# Made use (or non-use) of regex thread safe.
#
# Revision 1.14 1998/04/14 11:58:21 jim
# Fixed bug in handling: %(foo)d
# and in handling <!--#var foo--> where foo is a tuple.
...
...
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