[Zope] sorry for lame question...

Corey Saltiel corey@axcelerant.com
Sun, 26 Jan 2003 12:44:39 -0800


On Sunday 26 January 2003 11:35 am, Martin Gebert wrote:
> Corey Saltiel schrieb:
> ><span tal:replace="here/my_ZSql_method">
> >
> >Which provides:
> >
> >"<Shared.DC.ZRDB.Results.Results instance at 0x8c6df8c>"
> >
> >I don't want the instance - I want the value, of course.
>
> This is the object reference, and the values are, row by row, *in* this
> object. tal:replace doesn't iterate over the rows, but replaces the tag
> by the value of the object, which is this reference. 
>

  Understood. As a programmer, that "<Shared.DC.ZRDB.Results.Results instance at 
  0x8c6df8c>" result was obviously a reference - which I didn't want. 


> >( My lack of Python knowhow may make the obvious less so )
>
> Seems so. OO programming knowledge would help, too.
>

  It actualy appears, now that I see the correct TAL syntax - that neither
  Python *or* OOP knowledge ( which I have plenty of - I'm just not a python
  programmer yet ) - would have helped me guess the correct way of pulling
  ZSql row values with ZPT. I only had to guess because the official 
  documentation did not explain or demonstrate how.


> >Why can't ZPT be used in other places, like ZSql methods?
>
> 'cause ZPT isn't designed for logic, but you need logic in Z SQL (if,
> group, and etc.).
>

  There's no logic in the following ZSql:

select CompanyId 
from Users 
where UserId=<dtml-sqlvar expr="_.SecurityGetUser().getUserName()" type="string">

  
  Why can not the following be done:

select CompanyId 
from Users 
where UserId=tal:content="user/getUserName"

  ( this was what I, as a newbie, tried with my first ZSql method )

  Or something like:

select CompanyId 
from Users 
where UserId=tal:sqlvar="python: modules['AccessControl'].getSecurityManager().getUserName()"


  Notice how ZPT and DTML both have different idiosyncrasies - it's lame to have
  to learn both!  If there wasn't so much "magic" involved ( *much* less so with 
  ZPT compared to DTML ), it wouldn't be such a problem.
  

> > There is some serious
> >confusion on where to use ZPT and where to use DTML.
>
> Use ZPT in Page Templates, DTML in DTML-Documents, -Methods and Z SQL
> Methods. That's that.
>

  It makes sense that one would not stuff ZPT/TAL into a "DTML Document" or 
  a "DTML Method", just as it makes sense to not throw perl into a "Script 
  (Python)"...  that wasn't what I was getting at. 

  I was talking about the overlap between ZPT and DTML.

  It's obviously and understandably preferable - from a strictly academic
  standpoint - to use ZPT wherever possible, than DTML - which destroys all
  concepts of logic/presentation separation, and is rather ugly in my view.

  When a ton of the official, easily accessable docs out there all mostly use
  DTML ( even the Zope Tutorial! ) - then it really reduces the ease and thus
  the likelyhood of a newbie to ever start right off with ZPT. They'll either
  just go with DTML for everything, because it takes effort to learn and that's
  what most of the docs present; or they'll just get frustrated.


> > Why should a new user be
> >required to learn *both* -- especialy when it's arguable that ZPT is more
> >"correct" ( in so far as much as better separation of logic from
> > presentation, html/xml friendly, etc., etc. )
>
> See above - ZPT is for design and layout, not for logic. "Better" means
> "closer to the ideal of separating content and layout" here. DTML mixes
> both and therefore is more a "write only language" (read: bad to
> administrate). In ZPT you additionally need Python for logic (which you
> needed with DTML for everything more complicated anyways...).
>

  Then I - as someone who prefers to learn and strictly use ZPT - should be able
  to to write that ZSql method with ZPT, rather than DTML. And if/when logic is 
  required, then I'd have to use some python in addition.


> >I get the distinct impression from the zope-dev list that ZPT is,
> > generaly, the new desired replacement for DTML for most uses.
>
> You should now understand why, and in which cases. Or not...?
>

  I understand - and very much appreciate! - the fact that I could reasonably
  use ZPT and ZPT w/ python as a complete replacement for DTML documents and
  DTML methods. This is cool.

  What sucks, is that I have to learn DTML - which I'd rather didn't exist! - 
  just in order to do anything useful with ZSql methods. This defeats my desire
  to learn as little as possible in order to get as far as possible in as short
  a time period as possible. It also throws a serious monkey-wrench into my 
  learning curve. This is not being lazy - it's being productive. Needing to 
  learn both DTML and ZPT reduces my productivity.

  Am I making any sense here, or just rambling?

  I guess, to simplify - all I'm looking for is the ability to use ZPT in Zsql
  methods... is that such a crazy idea?