[Zope-dev] Porting EMarket to ZPatterns...possible good example

James Johnson jimbo@tacoma.zzn.com
Wed, 13 Sep 2000 22:53:39 -0700


<html><head><meta Name=3D'keywords' Content=3D'commtouch, pronto, mail, =
free email, free, branded, web based, free web based email, communicatio=
ns, internet, software, advertising banners, e-mail, free software'></he=
ad><body   ><div align=3D'left'><font   ><blockquote><blockquote><TT><BR=
>
I overlooked this posting somehow. &nbsp;I've now actually stored <BR>
something in a ZClass. &nbsp;This seems to be a good working example. <=
BR>
Thanks so much. &nbsp;I will play with the rest and see what I come up =
<BR>
with.<BR>
I had to post it again just in case others missed it like I did.<BR>
<BR>
<BR>
<BR>
<BR>
Thanks Phillip!<BR>
<BR>
OK. that helped a lot. The problem is that when things don't work<BR>
as I expect.. I guess (usually with a high degree of success)<BR>
that I am off base. Now I've just been experimenting with<BR>
this in a simpler 'dtml-only' way just to clarify how it's <BR>
supposed to work.<BR>
<BR>
I created a simple ZClass with no ZClass based propertysheets.<BR>
(The ZClass is called MyTestSkin, subclass of DataSkin)<BR>
<BR>
I created a specialists that manages instances of this ZClass.<BR>
(The specialist is called myTest)<BR>
<BR>
I set up the default rack of myTest with a PlugIn SheetProvider<BR>
with &quot;SheetNames&quot; set to &quot;ShopperData&quot;.<BR>
<BR>
Based on your last email the addShopper method in 'myTest' looks like <=
BR>
this:<BR>
<BR>
&lt;dtml-var standard_html_header&gt;<BR>
&lt;h2&gt;&lt;dtml-var title_or_id&gt; &lt;dtml-var document_title&gt;&=
lt;/h2&gt;<BR>
&lt;dtml-let newObj=3D&quot;newItem(REQUEST['id'])&quot;&gt;<BR>
&lt;dtml-if &quot;newObj.propertysheets.manage_addPropertySheet<BR>
(id=3D'ShopperData',ns=3D'')&quot;&gt;<BR>
&lt;dtml-let newPPS=3D&quot;newObj.propertysheets.get('ShopperData')&qu=
ot;&gt;<BR>
&lt;dtml-call &quot;newPPS.manage_addProperty<BR>
(id=3D'email',type=3D'string',value=3D'')&quot;&gt;<BR>
&lt;dtml-call &quot;newPPS.manage_addProperty<BR>
(id=3D'passwd',type=3D'string',value=3D'')&quot;&gt;<BR>
&lt;dtml-call &quot;newPPS.manage_addProperty<BR>
(id=3D'address',type=3D'string',value=3D'')&quot;&gt;<BR>
&lt;dtml-call &quot;newPPS.manage_changeProperties(REQUEST)&quot;&gt;<B=
R>
New Shopper Added!<BR>
&lt;form action=3D&quot;&lt;dtml-var &quot;myTest.absolute_url()&quot;&=
gt;&quot;&gt;<BR>
&lt;input type=3Dsubmit value=3D&quot;OK!&quot;&gt;<BR>
&lt;/form&gt;<BR>
<BR>
&lt;/dtml-let&gt;<BR>
&lt;dtml-else&gt;<BR>
Cannot add property sheet.<BR>
&lt;/dtml-if&gt;<BR>
&lt;/dtml-let&gt;<BR>
&lt;dtml-var standard_html_footer&gt;<BR>
<BR>
It seems to work OK. Now.. the index_html for my ZClass wants to look <=
BR>
like this:<BR>
<BR>
&lt;dtml-var standard_html_header&gt;<BR>
&lt;h2&gt;&lt;dtml-var title_or_id&gt; &lt;dtml-var document_title&gt;&=
lt;/h2&gt;<BR>
&lt;p&gt;<BR>
email: &lt;dtml-var &quot;email&quot;&gt;&lt;br&gt;<BR>
address: &lt;dtml-var &quot;address&quot;&gt;&lt;br&gt;<BR>
&lt;/p&gt;<BR>
&lt;/dtml-let&gt;<BR>
&lt;dtml-var standard_html_footer&gt;<BR>
<BR>
But I get 'KeyError&quot; on any attribute. I guess I thought that <BR>=

the SheetProvider would kick in when a request was made for 'email'<BR>=

and automagically search the instances propertysheets for an<BR>
attribute that matched. The following did work however:<BR>
<BR>
&lt;dtml-var standard_html_header&gt;<BR>
&lt;h2&gt;&lt;dtml-var title_or_id&gt; &lt;dtml-var document_title&gt;&=
lt;/h2&gt;<BR>
&lt;dtml-let myPPS=3D&quot;propertysheets.get('ShopperData')&quot;&gt;<=
BR>
&lt;p&gt;<BR>
email: &lt;dtml-var &quot;myPPS.getProperty('email')&quot;&gt;<BR>
address: &lt;dtml-var &quot;myPPS.getProperty('address')&quot;&gt;<BR>
&lt;/p&gt;<BR>
&lt;/dtml-let&gt;<BR>
&lt;dtml-var standard_html_footer&gt;<BR>
<BR>
<BR>
This doesn't seem quite right to me... when I use a <BR>
GenericAttributeProvider<BR>
that talks to a database... I can just say &lt;dtml-var foo&gt; and it =
<BR>
works.<BR>
I'm sure I'm still not getting something... but I don't know what. I <B=
R>
can look<BR>
at:<BR>
<BR>
/myTest/a/propertysheets/ShopperData/manage<BR>
<BR>
and it allows me to edit the instance's property sheet through<BR>
the web.. I was hoping (and maybe this is really really just<BR>
wrong...) that there was some 'central' propertsheet that could<BR>
be modified and thereby give all instances new properties.. sorta<BR>
like ZClass property sheets... <BR>
<BR>
Anyway.. I'm now off to try SkinScripts with these test cases...<BR>
<BR>
thanks!<BR>
-steve<BR>
<BR>
<BR>
_______________________________________________<BR>
Zope-Dev maillist =A0- =A0Zope-Dev@zope.org<BR>
http://lists.zope.org/mailman/listinfo/zope-dev<BR>
** =A0No cross posts or HTML encoding! =A0**<BR>
(Related lists - <BR>
 http://lists.zope.org/mailman/listinfo/zope-announce<BR>
 http://lists.zope.org/mailman/listinfo/zope )<BR>
<BR>
<BR>
<BR>
---- End Original Message ----<BR>
<BR>
<BR>
</TT><br><br><font><p align=3Dleft><br>Get your Free E-mail at http://t=
acoma.zzn.com<br>_______________________________________________________=
_____<br>Get your own Web-Based E-mail Service at http://www.zzn.com<br>=
</blockquote></blockquote></div></font></body></html>