[Zope] Interfacing with Z SQL Method?
Chris McDonough
chrism@digicool.com
Tue, 30 Nov 1999 11:22:03 -0500
> -----Original Message-----
> From: Art Hampton [mailto:arth@pacsg.css.mot.com]
> Sent: Tuesday, November 30, 1999 10:56 AM
> To: zope@zope.org
> Subject: [Zope] Interfacing with Z SQL Method?
>
>
> I'm having problems interfacing with an SQL method I've created.
>
> My method takes two arguments:
> ids:tokens:int="" limit:int="10"
>
> ids is a space separated list of news article category IDs (any if
> empty), and limit is the maximum number of articles I want returned.
>
> No problems so far, my method works as desired.
>
> Problem #1:
> My problem occurs with interfacing with the method. The
> auto-generated
> Z Search Interface can access the data just fine.
>
> But I want to create a document method which will call the
> SQL method.
> No query will have been performed at this point. I want to
> make a page
> which retrieves the category IDs of interest for the current user, and
> then uses that list for the ids parameter. I cannot figure out how I
> can set the ids parameter for the SQL method. My impression from
> reading the Z SQL Method guide is that the parameters are only taken
> from the variables given in the query (not applicable for the
> first view
> of this page), or from variables in the folder (which doesn't help me,
> since the ids vary with the user, not the folder).
>
> The following snippet of code works fine for the default arguments:
> <dtml-in SQL_GetHeadlineSummary size=20 start=qs>
> <B><dtml-var title></B>
> <UL><dtml-var body size=8 etc="..."></UL>
> </dtml-in>
>
> What do I need to do to get it to use values that I pass in? Or can I
> do that?
You can do something like this:
<dtml-call REQUEST.set('ids', '1 2 3')>
<dtml-call yourSQLMethod>
Is this what you mean?
>
>
> Problem #2:
> I'd like to pull in the headlines (discussed above) into the
> root level
> index_html. However, I don't want to make the above SQL
> method (or its
> connection) available to content managers in the levels below
> root (for
> security reasons).
>
> The only solution I've come up with (and keep in mind that I've only
> been using Zope for about 2 weeks) is to put the connection and method
> in a folder under root. But then I can't figure out how to pull the
> info contained in the subfolder up into the index_html at root.
>
> Any hints?
>
Make a folder on the root dir, maybe call it sqlMethods or something.
Then make some SQL methods inside this folder. Let's say for instance,
you've made a SQL method called "sqlSelectSomeRows" and you've put it in
a folder named "sqlMethods" (which is in the root folder).
Now let's also say you've also created a folder named "Content" off the
root, and inside of it you've put a DTML method called "showmyrows".
Inside showmyrows, you could refer to the sqlSelectSomeRows SQL method
by doing this:
<dtml-in
"sqlMethods.sqlSelectSomeRows(user_id=AUTHENTICATED_USER.getUserName())"
>
User name: <dtml-var user_name><br>
</dtml-in>
Is this what you mean?
> Thanks in advance for your help.
>
> _______________________________________________
> 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 )
>