[Zope-dev] Porting EMarket to ZPatterns....
Steve Spicklemire
steve@spvi.com
Sun, 27 Aug 2000 06:58:32 -0500 (EST)
Thanks Phillip!
OK. that helped a lot. The problem is that when things don't work
as I expect.. I guess (usually with a high degree of success)
that I am off base. Now I've just been experimenting with
this in a simpler 'dtml-only' way just to clarify how it's
supposed to work.
I created a simple ZClass with no ZClass based propertysheets.
(The ZClass is called MyTestSkin, subclass of DataSkin)
I created a specialists that manages instances of this ZClass.
(The specialist is called myTest)
I set up the default rack of myTest with a PlugIn SheetProvider
with "SheetNames" set to "ShopperData".
Based on your last email the addShopper method in 'myTest' looks like this:
<dtml-var standard_html_header>
<h2><dtml-var title_or_id> <dtml-var document_title></h2>
<dtml-let newObj="newItem(REQUEST['id'])">
<dtml-if "newObj.propertysheets.manage_addPropertySheet(id='ShopperData',ns='')">
<dtml-let newPPS="newObj.propertysheets.get('ShopperData')">
<dtml-call "newPPS.manage_addProperty(id='email',type='string',value='')">
<dtml-call "newPPS.manage_addProperty(id='passwd',type='string',value='')">
<dtml-call "newPPS.manage_addProperty(id='address',type='string',value='')">
<dtml-call "newPPS.manage_changeProperties(REQUEST)">
New Shopper Added!
<form action="<dtml-var "myTest.absolute_url()">">
<input type=submit value="OK!">
</form>
</dtml-let>
<dtml-else>
Cannot add property sheet.
</dtml-if>
</dtml-let>
<dtml-var standard_html_footer>
It seems to work OK. Now.. the index_html for my ZClass wants to look
like this:
<dtml-var standard_html_header>
<h2><dtml-var title_or_id> <dtml-var document_title></h2>
<p>
email: <dtml-var "email"><br>
address: <dtml-var "address"><br>
</p>
</dtml-let>
<dtml-var standard_html_footer>
But I get 'KeyError" on any attribute. I guess I thought that
the SheetProvider would kick in when a request was made for 'email'
and automagically search the instances propertysheets for an
attribute that matched. The following did work however:
<dtml-var standard_html_header>
<h2><dtml-var title_or_id> <dtml-var document_title></h2>
<dtml-let myPPS="propertysheets.get('ShopperData')">
<p>
email: <dtml-var "myPPS.getProperty('email')">
address: <dtml-var "myPPS.getProperty('address')">
</p>
</dtml-let>
<dtml-var standard_html_footer>
This doesn't seem quite right to me... when I use a GenericAttributeProvider
that talks to a database... I can just say <dtml-var foo> and it works.
I'm sure I'm still not getting something... but I don't know what. I can look
at:
/myTest/a/propertysheets/ShopperData/manage
and it allows me to edit the instance's property sheet through
the web.. I was hoping (and maybe this is really really just
wrong...) that there was some 'central' propertsheet that could
be modified and thereby give all instances new properties.. sorta
like ZClass property sheets...
Anyway.. I'm now off to try SkinScripts with these test cases...
thanks!
-steve