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
2fc80782
Commit
2fc80782
authored
May 28, 1999
by
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added contributed patch to Converters to allow :tokens:int type constructs
to work.
parent
dbd6fff8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
9 deletions
+9
-9
lib/python/ZPublisher/Converters.py
lib/python/ZPublisher/Converters.py
+9
-9
No files found.
lib/python/ZPublisher/Converters.py
View file @
2fc80782
...
...
@@ -82,10 +82,11 @@
# attributions are listed in the accompanying credits file.
#
##############################################################################
__version__
=
'$Revision: 1.
4
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.
5
$'
[
11
:
-
2
]
import
regex
from
string
import
atoi
,
atol
,
atof
,
join
,
split
,
strip
from
types
import
ListType
,
TupleType
def
field2string
(
v
):
if
hasattr
(
v
,
'read'
):
v
=
v
.
read
()
...
...
@@ -114,6 +115,8 @@ def field2required(v):
raise
ValueError
,
'No input for required field<p>'
def
field2int
(
v
):
if
type
(
v
)
in
(
ListType
,
TupleType
):
return
map
(
field2int
,
v
)
if
hasattr
(
v
,
'read'
):
v
=
v
.
read
()
else
:
v
=
str
(
v
)
# we can remove the check for an empty string when we go to python 1.4
...
...
@@ -121,6 +124,8 @@ def field2int(v):
raise
ValueError
,
'Empty entry when <strong>integer</strong> expected'
def
field2float
(
v
):
if
type
(
v
)
in
(
ListType
,
TupleType
):
return
map
(
field2float
,
v
)
if
hasattr
(
v
,
'read'
):
v
=
v
.
read
()
else
:
v
=
str
(
v
)
# we can remove the check for an empty string when we go to python 1.4
...
...
@@ -129,6 +134,8 @@ def field2float(v):
'Empty entry when <strong>floating-point number</strong> expected'
)
def
field2long
(
v
):
if
type
(
v
)
in
(
ListType
,
TupleType
):
return
map
(
field2long
,
v
)
if
hasattr
(
v
,
'read'
):
v
=
v
.
read
()
else
:
v
=
str
(
v
)
# we can remove the check for an empty string when we go to python 1.4
...
...
@@ -149,23 +156,16 @@ def field2date(v):
else
:
v
=
str
(
v
)
return
DateTime
(
v
)
def
field2date
(
v
):
from
DateTime
import
DateTime
if
hasattr
(
v
,
'read'
):
v
=
v
.
read
()
else
:
v
=
str
(
v
)
return
DateTime
(
v
)
def
field2boolean
(
v
):
return
v
ListType
=
type
([])
def
field2list
(
v
):
if
type
(
v
)
is
not
ListType
:
v
=
[
v
]
return
v
def
field2tuple
(
v
):
if
type
(
v
)
is
not
List
Type
:
v
=
(
v
,)
if
type
(
v
)
is
not
Tuple
Type
:
v
=
(
v
,)
return
tuple
(
v
)
type_converters
=
{
...
...
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