[Zope] getPropertyType

Tim Hicks tim@sitefusion.co.uk
Sat, 5 May 2001 18:23:51 +0100


----- Original Message -----
From: "marc lindahl" <marc@bowery.com>
To: "Tim Hicks" <tim@sitefusion.co.uk>; <zope@zope.org>
Sent: Saturday, May 05, 2001 4:46 PM
Subject: Re: [Zope] getPropertyType


> Tim,
> take a look at the python/OFS/dtml/properties.dtml code.

Sorted! Had a look at properties.dtml and what you suggested.  Here's what I
got to work.

<dtml-in "propertysheets.details.propertyMap()" mapping>
<dtml-let prop=sequence-item>
<tr>
<td valign="top"><dtml-var "prop.get('id')"></td>
<td><dtml-if "prop.get('type')=='text'"><textarea cols="60" rows="10"
name="<dtml-var "prop.get('id')">:text"><dtml-var
"propertysheets.details.getProperty(prop.get('id'))"></textarea><dtml-else><
input type="text" name="<dtml-var "prop.get('id')">:<dtml-var
"prop.get('type')">" value="<dtml-var
"propertysheets.details.getProperty(prop.get('id'))">"></dtml-if></td>
</tr>
</dtml-let>
</dtml-in>

Thanks for your help.


tim



> Something more like:
>
> <dtml-in details.propertyMap mapping>  -- not sure about that part, since
> properties.dtml is not for a subsheet.
>
> but anyway, use the mapping
>
> then you'd have:
>
>
> <tr>
> <th align="left"><dtml-var propertyLabel(id)></th>
> <td><dtml-if "type =='text'">
>  <textarea name="<dtml-var id>:text" rows="6" cols="35"><dtml-var
>    "getProperty(id)" html_quote></textarea>
> <dtml-else>
>   <input type="text" name="<dtml-var id>:<dtml-var
>    type>" size="35" value="<dtml-if "hasProperty(id)"><dtml-var
>    "'%s' % getProperty(id)" html_quote></dtml-if>">
> </dtml-if></td>
> </tr>
>
> ...but I'd suggest studying properties.dtml the code there is much more
> complete.
>
>
> > From: "Tim Hicks" <tim@sitefusion.co.uk>
> > Date: Sat, 5 May 2001 16:16:02 +0100
> > To: <zope@zope.org>
> > Subject: [Zope] getPropertyType
> >
> > I have a zclass that has a property sheet called 'details' and I am
trying
> > to create a form for editing this that goes through the property sheet
> > (using dtml-in) and creates the correct input box.  Everything works,
except
> > the getPropertyType part, which always returns 'None'.  The ZQR says
that it
> > will do this when the property doesn't exist, but the property clearly
does
> > exist as propertyIds() finds it, a getProperty() does actually return
the
> > value of the property.  I just want to see what sort of property it is
so
> > that I can present the correct type of input box.
> >
> > Here's the code snippet.
> >
> > <dtml-in "propertysheets.details.propertyIds()">
> > <dtml-let pid="_['sequence-item']">
> > <tr>
> > <th align="left"><dtml-var pid></th>
> > <td><dtml-if "propertysheets.details.getPropertyType(pid) ==
> > 'text'"><textarea  name="<dtml-var pid>"><dtml-var
> > "propertysheets.details.getProperty(pid)"></textarea><dtml-else><input
> > type=text name="<dtml-var pid>" value="<dtml-var
> > "propertysheets.details.getProperty(pid)">"></dtml-if></td>
> > <td><dtml-var "propertysheets.details.getPropertyType(pid)"></td>
> > </tr>
> > </dtml-let>
> > </dtml-in>
> >
> > And here is a sample of what it generates.
> >
> > <tr>
> > <th align="left">name</th>
> > <td><input type=text name="name" value="Tim Hicks"></td>
> > <td>None</td>
> > </tr>
> > <tr>
> > <th align="left">email</th>
> > <td><input type=text name="email" value="tim@sitefusion.co.uk"></td>
> > <td>None</td>
> > </tr>
> >
> >
> > Any ideas?
> >
> > tim
> >
> >
> > _______________________________________________
> > 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 )
>