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
981dccad
Commit
981dccad
authored
May 10, 2000
by
Tres Seaver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Collector #892: allow expr syntax for type, disposition, encode, name, filename; add skip_expr
parent
befc802c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
90 additions
and
30 deletions
+90
-30
lib/python/Products/MIMETools/MIMETag.py
lib/python/Products/MIMETools/MIMETag.py
+90
-30
No files found.
lib/python/Products/MIMETools/MIMETag.py
View file @
981dccad
...
@@ -82,8 +82,8 @@
...
@@ -82,8 +82,8 @@
# attributions are listed in the accompanying credits file.
# attributions are listed in the accompanying credits file.
#
#
##############################################################################
##############################################################################
__rcs_id__
=
'$Id: MIMETag.py,v 1.
4 2000/03/16 17:18:26 evan
Exp $'
__rcs_id__
=
'$Id: MIMETag.py,v 1.
5 2000/05/10 18:43:34 tseaver
Exp $'
__version__
=
'$Revision: 1.
4
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.
5
$'
[
11
:
-
2
]
from
DocumentTemplate.DT_Util
import
*
from
DocumentTemplate.DT_Util
import
*
from
DocumentTemplate.DT_String
import
String
from
DocumentTemplate.DT_String
import
String
...
@@ -106,12 +106,25 @@ class MIMETag:
...
@@ -106,12 +106,25 @@ class MIMETag:
for
tname
,
args
,
section
in
blocks
:
for
tname
,
args
,
section
in
blocks
:
if
tname
==
'mime'
:
if
tname
==
'mime'
:
args
=
parse_params
(
args
,
type
=
None
,
disposition
=
None
,
args
=
parse_params
(
args
encode
=
None
,
name
=
None
,
multipart
=
None
)
,
type
=
None
,
type_expr
=
None
,
disposition
=
None
,
disposition_expr
=
None
,
encode
=
None
,
encode_expr
=
None
,
name
=
None
,
name_expr
=
None
,
filename
=
None
,
filename_expr
=
None
,
skip_expr
=
None
,
multipart
=
None
)
self
.
multipart
=
args
.
get
(
'multipart'
,
'mixed'
)
self
.
multipart
=
args
.
get
(
'multipart'
,
'mixed'
)
else
:
else
:
args
=
parse_params
(
args
,
type
=
None
,
disposition
=
None
,
args
=
parse_params
(
args
encode
=
None
,
name
=
None
)
,
type
=
None
,
type_expr
=
None
,
disposition
=
None
,
disposition_expr
=
None
,
encode
=
None
,
encode_expr
=
None
,
name
=
None
,
name_expr
=
None
,
filename
=
None
,
filename_expr
=
None
,
skip_expr
=
None
)
has_key
=
args
.
has_key
has_key
=
args
.
has_key
...
@@ -120,29 +133,51 @@ class MIMETag:
...
@@ -120,29 +133,51 @@ class MIMETag:
else
:
else
:
type
=
'application/octet-stream'
type
=
'application/octet-stream'
if
has_key
(
'type_expr'
):
if
has_key
(
'type'
):
raise
ParseError
,
_tm
(
'type and type_expr given'
,
'mime'
)
args
[
'type_expr'
]
=
VSEval
.
Eval
(
args
[
'type_expr'
],
expr_globals
)
elif
not
has_key
(
'type'
):
args
[
'type'
]
=
'application/octet-stream'
if
has_key
(
'disposition_expr'
):
if
has_key
(
'disposition'
):
if
has_key
(
'disposition'
):
disposition
=
args
[
'disposition'
]
raise
ParseError
,
_tm
(
'disposition and disposition_expr given'
,
'mime'
)
else
:
args
[
'disposition_expr'
]
=
VSEval
.
Eval
(
args
[
'disposition_expr'
],
expr_globals
)
disposition
=
''
elif
not
has_key
(
'disposition'
):
args
[
'disposition'
]
=
''
if
has_key
(
'encode_expr'
):
if
has_key
(
'encode'
):
if
has_key
(
'encode'
):
encode
=
args
[
'encode'
]
raise
ParseError
,
_tm
(
'encode and encode_expr given'
,
'mime'
)
else
:
args
[
'encode_expr'
]
=
VSEval
.
Eval
(
args
[
'encode_expr'
],
expr_globals
)
encode
=
'base64'
elif
not
has_key
(
'encode'
):
args
[
'encode'
]
=
'base64'
if
has_key
(
'name_expr'
):
if
has_key
(
'name'
):
if
has_key
(
'name'
):
name
=
args
[
'name'
]
raise
ParseError
,
_tm
(
'name and name_expr given'
,
'mime'
)
else
:
args
[
'name_expr'
]
=
VSEval
.
Eval
(
args
[
'name_expr'
],
expr_globals
)
name
=
''
elif
not
has_key
(
'name'
):
args
[
'name'
]
=
''
if
encode
not
in
\
if
has_key
(
'filename_expr'
):
if
has_key
(
'filename'
):
raise
ParseError
,
_tm
(
'filename and filename_expr given'
,
'mime'
)
args
[
'filename_expr'
]
=
VSEval
.
Eval
(
args
[
'filename_expr'
],
expr_globals
)
elif
not
has_key
(
'filename'
):
args
[
'filename'
]
=
''
if
has_key
(
'skip_expr'
):
args
[
'skip_expr'
]
=
VSEval
.
Eval
(
args
[
'skip_expr'
],
expr_globals
)
if
args
[
'encode'
]
not
in
\
(
'base64'
,
'quoted-printable'
,
'uuencode'
,
'x-uuencode'
,
(
'base64'
,
'quoted-printable'
,
'uuencode'
,
'x-uuencode'
,
'uue'
,
'x-uue'
,
'7bit'
):
'uue'
,
'x-uue'
,
'7bit'
):
raise
MIMEError
,
(
raise
MIMEError
,
(
'An unsupported encoding was specified in tag'
)
'An unsupported encoding was specified in tag'
)
self
.
sections
.
append
((
type
,
disposition
,
encode
,
self
.
sections
.
append
((
args
,
section
.
blocks
))
name
,
section
.
blocks
))
def
render
(
self
,
md
):
def
render
(
self
,
md
):
...
@@ -150,10 +185,33 @@ class MIMETag:
...
@@ -150,10 +185,33 @@ class MIMETag:
mw
=
MimeWriter
(
StringIO
())
mw
=
MimeWriter
(
StringIO
())
outer
=
mw
.
startmultipartbody
(
self
.
multipart
)
outer
=
mw
.
startmultipartbody
(
self
.
multipart
)
for
x
in
self
.
sections
:
for
x
in
self
.
sections
:
a
,
b
=
x
has_key
=
a
.
has_key
if
has_key
(
'skip_expr'
)
and
a
[
'skip_expr'
].
eval
(
md
):
continue
inner
=
mw
.
nextpart
()
inner
=
mw
.
nextpart
()
t
,
d
,
e
,
n
,
b
=
x
if
has_key
(
'type_expr'
):
t
=
a
[
'type_expr'
].
eval
(
md
)
else
:
t
=
a
[
'type'
]
if
has_key
(
'disposition_expr'
):
d
=
a
[
'disposition_expr'
].
eval
(
md
)
else
:
d
=
a
[
'disposition'
]
if
has_key
(
'encode_expr'
):
e
=
a
[
'encode_expr'
].
eval
(
md
)
else
:
e
=
a
[
'encode'
]
if
has_key
(
'name_expr'
):
n
=
a
[
'name_expr'
].
eval
(
md
)
else
:
n
=
a
[
'name'
]
if
has_key
(
'filename_expr'
):
f
=
a
[
'filename_expr'
].
eval
(
md
)
else
:
f
=
a
[
'filename'
]
if
d
:
if
d
:
if
f
:
inner
.
addheader
(
'Content-Disposition'
,
'%s;
\
n
filename="%s"'
%
(
d
,
f
))
else
:
inner
.
addheader
(
'Content-Disposition'
,
d
)
inner
.
addheader
(
'Content-Disposition'
,
d
)
inner
.
addheader
(
'Content-Transfer-Encoding'
,
e
)
inner
.
addheader
(
'Content-Transfer-Encoding'
,
e
)
...
@@ -173,6 +231,8 @@ class MIMETag:
...
@@ -173,6 +231,8 @@ class MIMETag:
output
.
seek
(
0
)
output
.
seek
(
0
)
innerfile
.
write
(
output
.
read
())
innerfile
.
write
(
output
.
read
())
# XXX what if self.sections is empty ??? does it matter that mw.lastpart() is called
# right after mw.startmultipartbody() ?
if
x
is
self
.
sections
[
-
1
]:
if
x
is
self
.
sections
[
-
1
]:
mw
.
lastpart
()
mw
.
lastpart
()
...
...
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