[Zope] attributes Runtime error when using ZODB File Storage

Andreas Jung andreas at andreas-jung.com
Tue Oct 21 05:57:28 EDT 2003


Very sick idea :-)I

acl_users._doAddUser(name, password, roles, domains)
does the job for you. See AccessControl/User.py

-aj

--On Dienstag, 21. Oktober 2003 11:53 Uhr +0200 Ruth Mizzi <ruth at anvil.com> 
wrote:

> Hi,
>
> I'm using the ZODB storage for the first time and am basically tring to
> add some user info to a FileStorage object. My code is a python script
> pasted below. My problem is that when I'm trying to test this in the Zope
> management interface I keep getting the error:
>
> Error Type: RuntimeError
> Error Value: function attributes not accessible in restricted mode
>
>
> .... any idea what could be causing this problem and, more importantly,
> how I can solve it??
>
>
>
> Cheers
>
> Ruth
>
>
> import ZODB
> from ZODB import DB
> from ZODB.FileStorage import FileStorage
> from ZODB.PersistentMapping import PersistentMapping
> from Persistence import Persistent
>
> class AnvilUser(Persistent):
>     def setUserName(self, username): self.username = username
>     def setFullName(self, fname): self.fname = fname
>     def setSurName(self, surname): self.surname = surname
>     def setEMail(self, email): self.email = email
>
>
> storage = FileStorage('anvilusers.fs')
> db = DB(storage)
> connection = db.open()
> root = connection.root()
> if not root.has_key('users'):root["users"] = {}
> users = root['users']
> anviluser = AnvilUser()
> anviluser.setUsername(username)
> anviluser.setFullName(fname)
> anviluser.setSurName(surname)
> anviluser.setEMail(email)
> users.append(anviluser)
> root['users'] = users
> get_transaction.commit()
> connection.close()







More information about the Zope mailing list