[ZPT] Content/Presentation Separation

Godefroid Chapelle gotcha@swing.be
Wed, 24 Apr 2002 14:32:25 +0200


At 19:44 23/04/2002, Grant Thibdeau wrote:
>This should be a zpt question because it ultimately ends up in the zpt. If=
=20
>it's not my apologies.  I have my page template, which calls a python=20
>script.  This python script gets some data and then formats it. Now, I can=
=20
>then put a big print statement in my script to output all that information=
=20
>like so:
>
>print "Quantity Special: Each box is only %s a box!" % (resRebatePrice)
>
>return printed
>
>Now, from what I can tell that is kind of wrong, because i'm not really=20
>separating my content from my presentation.  Or would this be acceptable=20
>separation?  I'm assuming I would want to access a formatted=20
>resRebatePrice inside of a ZPT, but how would I get a hold of it inside=20
>the zpt?  Define the script call then access it like=20
>tal:content=3D"PythonScript/resRebatePrice" ?
>
>Thanks

I am not sure this will help but I think that the architecture that should=
=20
be used with ZPT is really different from DTML.
Really often people begin with ZPT and then try to access and or manipulate=
=20
data through the call of python scripts from ZPT.

I think that it should work exactly the way around :
URL traversal should arrive on a Python script which access data and=20
prepares it before passing it to a Page template.

example updateRecordForm

# initialize

request =3D context.REQUEST

# prepare data

records =3D context.storage.SQL_primaryKeySelect(request)
if request.has_key('errorMap'):
   errorMap =3D request.errorMap
else:
   errorMap =3D {}


# pass data and return template

return context.PT_updateRecordForm(record=3Drecords[0], errorMap=3DerrorMap)


my 2 =80 cents
--

Godefroid Chapelle

BubbleNet sprl
rue Victor Horta, 18 / 202
1348 Louvain-la-Neuve
Belgium

Tel + 32 (10) 459901
Mob + 32 (477) 363942

TVA 467 093 008
RC Niv 49849