[Zope] Appending to a file in Python

Laura McCord Laura.McCord at doucet-austin.com
Thu May 20 12:36:36 EDT 2004


I have been getting an error : 'file' object has no attribute 'append'

I am trying to append a new user on my .htaccess file and once I figure
this part I think the rest of my code will work perfectly.

This is a snippet of where the error is coming from:
Basically if the dirpath exists I want a new required user appended to
the list. I am still new to python so if something looks really wacky -
sorry. ;) 

def createUser(username, basedir):
 import os
 dirpath = "/var/www/html/da/" + basedir + "/.htaccess"
 if os.path.isfile(dirpath):
   filename=open(dirpath, 'a')
   filename.append('Require user ' + username + '\n')

Thanks

  



More information about the Zope mailing list