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
e7786abf
Commit
e7786abf
authored
Oct 02, 1998
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Automatically get id (and title) from file name.
parent
4e3ddbd5
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
1 deletion
+15
-1
lib/python/OFS/Image.py
lib/python/OFS/Image.py
+15
-1
No files found.
lib/python/OFS/Image.py
View file @
e7786abf
"""Image object"""
"""Image object"""
__version__
=
'$Revision: 1.4
3
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.4
4
$'
[
11
:
-
2
]
import
Globals
import
Globals
from
Globals
import
HTMLFile
,
MessageDialog
from
Globals
import
HTMLFile
,
MessageDialog
...
@@ -9,6 +9,7 @@ from SimpleItem import Item_w__name__
...
@@ -9,6 +9,7 @@ from SimpleItem import Item_w__name__
from
Persistence
import
Persistent
from
Persistence
import
Persistent
from
Acquisition
import
Implicit
from
Acquisition
import
Implicit
from
DateTime
import
DateTime
from
DateTime
import
DateTime
import
string
manage_addFileForm
=
HTMLFile
(
'imageAdd'
,
globals
(),
Kind
=
'File'
,
kind
=
'file'
)
manage_addFileForm
=
HTMLFile
(
'imageAdd'
,
globals
(),
Kind
=
'File'
,
kind
=
'file'
)
def
manage_addFile
(
self
,
id
,
file
,
title
=
''
,
precondition
=
''
,
REQUEST
=
None
):
def
manage_addFile
(
self
,
id
,
file
,
title
=
''
,
precondition
=
''
,
REQUEST
=
None
):
...
@@ -16,6 +17,7 @@ def manage_addFile(self,id,file,title='',precondition='',REQUEST=None):
...
@@ -16,6 +17,7 @@ def manage_addFile(self,id,file,title='',precondition='',REQUEST=None):
Creates a new file object 'id' with the contents of 'file'"""
Creates a new file object 'id' with the contents of 'file'"""
id
,
title
=
cookId
(
id
,
title
,
file
)
self
.
_setObject
(
id
,
File
(
id
,
title
,
file
,
precondition
))
self
.
_setObject
(
id
,
File
(
id
,
title
,
file
,
precondition
))
if
REQUEST
is
not
None
:
return
self
.
manage_main
(
self
,
REQUEST
)
if
REQUEST
is
not
None
:
return
self
.
manage_main
(
self
,
REQUEST
)
...
@@ -51,6 +53,7 @@ class File(Persistent,Implicit,RoleManager,Item_w__name__):
...
@@ -51,6 +53,7 @@ class File(Persistent,Implicit,RoleManager,Item_w__name__):
def
__init__
(
self
,
id
,
title
,
file
,
def
__init__
(
self
,
id
,
title
,
file
,
precondition
=
''
,
content_type
=
'application/octet-stream'
):
precondition
=
''
,
content_type
=
'application/octet-stream'
):
try
:
headers
=
file
.
headers
try
:
headers
=
file
.
headers
except
:
headers
=
None
except
:
headers
=
None
if
headers
is
None
:
if
headers
is
None
:
...
@@ -171,6 +174,7 @@ def manage_addImage(self,id,file,title='',REQUEST=None):
...
@@ -171,6 +174,7 @@ def manage_addImage(self,id,file,title='',REQUEST=None):
Creates a new Image object 'id' with the contents of 'file'.
Creates a new Image object 'id' with the contents of 'file'.
"""
"""
id
,
title
=
cookId
(
id
,
title
,
file
)
self
.
_setObject
(
id
,
Image
(
id
,
title
,
file
))
self
.
_setObject
(
id
,
Image
(
id
,
title
,
file
))
if
REQUEST
is
not
None
:
return
self
.
manage_main
(
self
,
REQUEST
)
if
REQUEST
is
not
None
:
return
self
.
manage_main
(
self
,
REQUEST
)
...
@@ -197,6 +201,16 @@ class Image(File):
...
@@ -197,6 +201,16 @@ class Image(File):
def
__str__
(
self
):
def
__str__
(
self
):
return
'<IMG SRC="%s" ALT="%s">'
%
(
self
.
__name__
,
self
.
title_or_id
())
return
'<IMG SRC="%s" ALT="%s">'
%
(
self
.
__name__
,
self
.
title_or_id
())
def
cookId
(
id
,
title
,
file
):
if
not
id
and
hasattr
(
file
,
'filename'
):
filename
=
file
.
filename
title
=
title
or
filename
id
=
filename
[
max
(
string
.
rfind
(
filename
,
'/'
),
string
.
rfind
(
filename
,
'
\
\
'
),
string
.
rfind
(
filename
,
':'
),
)
+
1
:]
return
id
,
title
class
Pdata
(
Persistent
,
Implicit
):
class
Pdata
(
Persistent
,
Implicit
):
# Wrapper for possibly large data
# Wrapper for possibly large data
def
__init__
(
self
,
data
):
def
__init__
(
self
,
data
):
...
...
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