[Zope] Avoiding AttributeErrors in SkinScript

Itai Tavor itai@optusnet.com.au
Fri, 16 Feb 2001 18:35:30 +1100


Hi,

I have the following SkinScript (greatly simplified):

     WITH Parties.getPersonForEmail(self.id) COMPUTE
       party=RESULT

     WITH self.party COMPUTE
       member_id=email

If getPersonForEmail returns None, the second clause returns 
AttributeError: party. If I change the first clause to party=RESULT 
or '', I can change the second to:

     WITH (self.party is not '') and self.party.email or '' COMPUTE
       member_id=RESULT

But this is both ugly and bad - in the real script I have many 
clauses using party, so repeating this nonsense in all of them is 
very wasteful, and also it would be better if party is set to None 
when a Person is not found. But if party is set to None, the DataSkin 
considers it to be undefined, so I can't do WITH (self.party is not 
_.None)...

Is there any nicer way of preventing AttributeErrors in clauses that 
try to access an attribute that was set to None?

TIA, Itai
-- 
--
Itai Tavor                      -- "Je sautille, donc je suis."    --
itai@optusnet.com.au            --               - Kermit the Frog --
-- 'Supposing a tree fell down, Pooh, when we were underneath it?' --
-- 'Supposing it didn't,' said Pooh after careful thought.         --