[Zope] ZClass question - array of arrays

Chris McDonough chrism@zope.com
Sun, 15 Sep 2002 11:06:36 -0400


Hi Dianne,

This type of data structure can't be directly entered using any of the 
existing property types.

You'll need to either write your own kind of property sheet view (which 
isn't actually a property sheet, more like a custom data entry form that 
you later pick apart), or allow people to enter in a Python expression 
which you later (unsafely) use "eval" against or (more safely) use a 
TALES "safe" Expression type to evaluate.  See 
http://www.zopelabs.com/cookbook/1029970670 for more information.



Dianne Van Dulken wrote:
> Hi, 
> 
> I'm having a little bit of a problem working out what ZClass property I
> should be setting.  I want to record an array that can either contain
> strings or more arrays.
> 
> eg:
> 
> It can be 
> 
> ['a', 'b', 'c'] 
> 
> or 
> 
> ['a', ['b', 'c'], 'd']
> 
> or 
> 
> [['a','b'], ['c','d'], ['e','f']]
> 
> The problem is that I can't work out what property type I should be setting
> this to be.  I tried tokens, but tokens won't allow arrays to be saved, and
> both lines and strings assume that there will be a string (obviously), which
> means that I have to do a lot of splitting on [ and , before I can work with
> the data.  The whole idea of the property is that if there is a scalar in
> position X, it shows the scalar, otherwise with an array, it shows a random
> value from that array.
> 
> Is there an obvious type that I am missing?
> 
> Thanks
> 
> Dianne
> 
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists - 
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope-dev )

-- 
Chris McDonough                    Zope Corporation
http://www.zope.org             http://www.zope.com
"Killing hundreds of birds with thousands of stones"