Commit 27943ba6 authored by Jim Fulton's avatar Jim Fulton

Changed Image View tab to include tabs.

Added getSize and getContentType.
parent 888f1f78
"""Image object""" """Image object"""
__version__='$Revision: 1.32 $'[11:-2] __version__='$Revision: 1.33 $'[11:-2]
import Globals import Globals
from Globals import HTMLFile, MessageDialog from Globals import HTMLFile, MessageDialog
...@@ -26,25 +26,17 @@ class File(Persistent,Implicit,RoleManager,Item_w__name__): ...@@ -26,25 +26,17 @@ class File(Persistent,Implicit,RoleManager,Item_w__name__):
manage_uploadForm=HTMLFile('imageUpload',globals(),Kind='File',kind='file') manage_uploadForm=HTMLFile('imageUpload',globals(),Kind='File',kind='file')
manage=manage_main=manage_editForm manage=manage_main=manage_editForm
manage_options=({'label':'Edit', 'action':'manage_main', manage_options=({'label':'Edit', 'action':'manage_main'},
'target':'manage_main', {'label':'Upload', 'action':'manage_uploadForm'},
}, {'label':'View', 'action':'view_image_or_file'},
{'label':'Upload', 'action':'manage_uploadForm', {'label':'Security', 'action':'manage_access'},
'target':'manage_main',
},
{'label':'View', 'action':'index_html',
'target':'manage_main',
},
{'label':'Security', 'action':'manage_access',
'target':'manage_main',
},
) )
__ac_permissions__=( __ac_permissions__=(
('View management screens', ['manage','manage_tabs','manage_uploadForm']), ('View management screens', ['manage','manage_tabs','manage_uploadForm']),
('Change permissions', ['manage_access']), ('Change permissions', ['manage_access']),
('Change/upload data', ['manage_edit','manage_upload','PUT']), ('Change/upload data', ['manage_edit','manage_upload','PUT']),
('View', ['index_html',]), ('View', ['index_html', 'view_image_or_file', 'getSize', 'getContentType']),
('Shared permission', ['',]), ('Shared permission', ['',]),
) )
...@@ -77,6 +69,8 @@ class File(Persistent,Implicit,RoleManager,Item_w__name__): ...@@ -77,6 +69,8 @@ class File(Persistent,Implicit,RoleManager,Item_w__name__):
RESPONSE['content-type'] =self.content_type RESPONSE['content-type'] =self.content_type
return self.data return self.data
def view_image_or_file(self, RESPONSE): return self.index_html(RESPONSE)
def manage_edit(self,title,content_type,REQUEST=None): def manage_edit(self,title,content_type,REQUEST=None):
""" """ """ """
self.title=title self.title=title
...@@ -113,6 +107,17 @@ class File(Persistent,Implicit,RoleManager,Item_w__name__): ...@@ -113,6 +107,17 @@ class File(Persistent,Implicit,RoleManager,Item_w__name__):
if type: self.content_type=type if type: self.content_type=type
except KeyError: pass except KeyError: pass
def getSize(self):
"""Get the size of a file or image
"""
return len(self.data)
def getContentType(self):
"""Get the content type of a file or image
"""
return self.content_type
def size(self): return len(self.data) def size(self): return len(self.data)
def __str__(self): return str(self.data) def __str__(self): return str(self.data)
def __len__(self): return 1 def __len__(self): return 1
...@@ -129,6 +134,7 @@ class Image(File): ...@@ -129,6 +134,7 @@ class Image(File):
icon ='p_/image' icon ='p_/image'
manage_editForm =HTMLFile('imageEdit',globals(),Kind='Image',kind='image') manage_editForm =HTMLFile('imageEdit',globals(),Kind='Image',kind='image')
view_image_or_file =HTMLFile('imageView',globals())
manage_uploadForm=HTMLFile('imageUpload',globals(),Kind='Image', manage_uploadForm=HTMLFile('imageUpload',globals(),Kind='Image',
kind='image') kind='image')
manage=manage_main=manage_editForm manage=manage_main=manage_editForm
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment