Commit 9e4a2d94 authored by Jim Fulton's avatar Jim Fulton

Added PUT.

Modified editing interface to:
  - Support editing content-type,
  - Separate changing properties and data.
parent a2b3ec83
"""Image object"""
__version__='$Revision: 1.10 $'[11:-2]
__version__='$Revision: 1.11 $'[11:-2]
from Persistence import Persistent
from Globals import HTMLFile
......@@ -18,32 +18,23 @@ class Image(Persistent,RoleManager,SimpleItem.Item_w__name__,
manage_editForm =HTMLFile('OFS/imageEdit')
manage=manage_main=manage_editForm
def manage_edit(self,title,file='',content_type='',
def manage_edit(self,title,content_type,
acl_type='A',acl_roles=[], REQUEST=None):
""" """
try: headers=file.headers
except: headers=None
if headers is None and file:
if not content_type: raise 'BadValue', (
'No content type specified')
self.content_type=content_type
self.data=file
elif file:
try:
data=file.read()
content_type=headers['content-type']
if data:
self.data=data
self.content_type=content_type
except: pass
self.title=title
self.content_type=content_type
self.title=title
self._setRoles(acl_type,acl_roles)
return MessageDialog(
title ='Changed %s' % self.__name__,
message='%s has been updated' % self.__name__,
action =REQUEST['URL2']+'/manage_main',
target ='manage_main')
if REQUEST: return self.manage_editedDialog(REQUEST)
def manage_editData(self,file='', REQUEST=None):
"""Change image data"""
headers=file.headers
data=file.read()
content_type=headers['content-type']
self.data=data
self.content_type=content_type
if REQUEST: return self.manage_editedDialog(REQUEST)
def _init(self,id,file,content_type=''):
try: headers=file.headers
......@@ -72,6 +63,15 @@ class Image(Persistent,RoleManager,SimpleItem.Item_w__name__,
# This is bogus and needed because of the way Python tests truth.
return 1
PUT__roles__='manage',
def PUT(self, BODY, REQUEST):
'handle PUT requests'
self.data=BODY
try:
type=REQUEST['CONTENT_TYPE']
if type: self.content_type=type
except KeyError: pass
class ImageHandler:
"""Image object handler mixin"""
......
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