[Zope-dev] Saving attributes for a DataSkin

Johan Carlsson johanc@torped.se
Thu, 8 Mar 2001 00:48:03 +0100


Hi,
I'm having some trouble figuring out how to write a method
and a skinscript to save attributes of a DataSkin.

Specialist is the LoginManager.

DataSkin is:

class EasyGroupUser(LoginUser):
    ...
    def getRoles(self):
        ...
    def getDomains(self):
        ...       =20
    def authenticate(self, password, request):
        ...

SkinScripts are:
WITH QUERY=20
        sql_getUserFor(username=3Dself.id)
COMPUTE=20
        username,=20
        password,=20
        challenge_question,=20
        challenge_answer,=20
        admin_email

WHEN OBJECT CHANGED STORE=20
        password,=20
        challenge_question,=20
        challenge_answer,=20
        admin_email
USING
    sql_changeUser(
        username=3Dself.id,
        newpassword=3Dpassword,=20
        challenge_question=3Dchallenge_question,=20
        challenge_answer=3Dchallenge_answer,=20
        admin_email=3Dadmin_email,
        oldpassword=3DOLD['oldpassword']
    )
SAVING
    oldpassword =3D password

Current Attribute Handling:
    admin_email=20
        Getters: SkinScript, line 1
        Setters: SkinScript, line 10
        Deleters: SkinScript, line 10
    challenge_answer=20
        Getters: SkinScript, line 1
        Setters: SkinScript, line 10
        Deleters: SkinScript, line 10
    challenge_question=20
        Getters: SkinScript, line 1
        Setters: SkinScript, line 10
        Deleters: SkinScript, line 10
    password=20
        Getters: SkinScript, line 1
        Setters: SkinScript, line 10
        Deleters: SkinScript, line 10


The getter works alright, but when trying to set attributes (that
supposedly would be handle by the setter) with the following
Script (Python) I get the following error:

## Script (Python) "changeUser"
##bind container=3Dcontainer
##bind context=3Dcontext
##bind namespace=3Dself
##bind script=3Dscript
##bind subpath=3Dtraverse_subpath
##parameters=3Dusername,password,challenge_question,challenge_answer,admi=
n_email
##title=3D
##
user =3D context.getItem(username)
user.password=3Dpassword
user.challenge_question=3Dchallenge_question
user.challenge_answer=3Dchallenge_answer
user.admin_email=3Dadmin_email

ERROR MESSAGE:
Error Type: TypeError
Error Value: attribute-less object (assign or del)

So what am I doing wrong here?
Any clues appreciated.
TIA/Johan Carlsson