[Zope-dev] Re: ZPatterns: __getitem__ on a DataSkin instance
Steve Alexander
steve@cat-box.net
Fri, 05 Jan 2001 21:08:57 +0000
Steve Alexander wrote:
> Let's say I have a DataSkin-derived ZClass that has the attribute
> "forename" (in a dataskin attribute propertysheet).
>
> If I get an instance of this ZClass from the ZODB (set up to use a
> Folder w/ customizer suppport), I can refer to the "forename" attribute
> using <dtml-var "this()['forename']">.
>
> However, if I get an instance of the same class from a Specialist,
> <dtml-var "this()['forename']"> gives me
>
> Error Type: AttributeError
> Error Value: __getitem__
>
> Any idea why there's the difference?
>
> Can the latter case be fixed?
A workaround, using the ever-flexible skinscript:
I've defined __getitem__ through skinscript and a PythonScript.
SkinScript:
WITH SELF COMPUTE __getitem__=getattr
PythonScript:
parameter list: index
return getattr(index)
--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.net