attributes Runtime error when using ZODB File Storage
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()
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@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()
I do have that solution implemented just now but I thought of using File Storage seeing that I need to store additional user info such as address, email etc. anything else I can use ? Ruth ----- Original Message ----- From: "Andreas Jung" <andreas@andreas-jung.com> To: "Ruth Mizzi" <ruth@anvil.com>; <zope@zope.org> Sent: Tuesday, October 21, 2003 11:57 AM Subject: Re: [Zope] attributes Runtime error when using ZODB File Storage
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@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()
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
On Tue, 2003-10-21 at 02:53, Ruth Mizzi 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.
This is your problem. Pythons scripts are not the right tool for defining persistent objects, you want to be using Python Products. To get started for how to do this: http://zope.org/Members/maxm/HowTo/minimal_01 http://www.zope.org/Members/maxm/HowTo/minimal_02 http://www.zope.org/Documentation/Books/ZDG/current HTH, Dylan
participants (3)
-
Andreas Jung -
Dylan Reinhardt -
Ruth Mizzi