[Zope] Python question

Laura McCord Laura.McCord at doucet-austin.com
Tue Nov 9 10:21:39 EST 2004


Andreas,

 I used what you recommended but now when I try to view the uploaded
file it comes up blank.
Is there a step that I am not doing?

spaceAvail = context.Availability()
data = file.read()
fileSize = len(data)
fileSize = (fileSize/1024)/1024

if spaceAvail < 80:
 if fileSize < 30:
  sizeTest = context.getDirectories('/var/www/html/da')
  if sizeTest > 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})


Thank You, 
 Laura


-----Original Message-----
From: Andreas Jung [mailto:lists at andreas-jung.com] 
Sent: Monday, November 08, 2004 11:16 AM
To: Laura McCord; zope at zope.org
Subject: Re: [Zope] Python question




--On Montag, 8. November 2004 11:10 Uhr -0600 Laura McCord 
<Laura.McCord at doucet-austin.com> wrote:

> I am writing a Python Script and I am trying to get the size of an 
> uploaded file. Does anyone know what I should use? I thought that I 
> could use len() but I was getting an error using it.

data = uploaded_file.read()
print len(data)

*must* work.

-aj


More information about the Zope mailing list