[Zope] Python Script Trouble
Laura McCord
Laura.McCord at doucet-austin.com
Mon Nov 8 15:48:12 EST 2004
I am having a problem with finding the uploaded fileSize. Currently whe
I use the file.read() function when I view the contents of the file
after it is uploaded it is blank. Perhaps, someone can see what I am
doing wrong. Here is my code:
# I am passing the uploaded file, title, id ....
REQUEST = context.REQUEST
new_context = context.portal_factory.doCreate(context, id)
# Generic editing method (ie. edits id + Metadata)
new_context.plone_utils.contentEdit(new_context, id = id, title = title,
)
spaceAvail = context.Availability()
data = file.read()
fileSize = len(data)
if spaceAvail < 80:
if fileSize < 30:
sizeTest = context.getDirectories('/var/www/html/da')
totalSize = fileSize + sizeTest
if totalSize > 900:
message = 'Failure: No available disk space, see system
administrator'
return ('failure', new_context,{'portal_status_message':message})
else:
test = new_context.manage_editPloneExternalFile(title = title,file =
file,REQUEST = REQUEST)
if not test:
return ('success',
new_context,{'portal_status_message':context.REQUEST.get('portal_status_
message', 'Content updated.')})
else:
return ('failure', new_context,{'portal_status_message':test})
else:
errormsg = 'Failure: File exceeds size limitation of 30MB'
return ('failure', new_context,{'portal_status_message':fileSize})
else:
errormsg2 = 'Failure: No disk space available in /var directory'
return ('failure', new_context,{'portal_status_message':errormsg2})
Thanks You.
More information about the Zope
mailing list