quick search:
 

Display and edit all ZSql methods

Submitted by: tgraham
Last Edited: 2001-07-28

Category: ZSQL and SQL DA

Average rating is: 0.0 out of 5 (0 ratings)

Description:
This a combination of pup's earlier release of "Display all ZSQL
Methods" and the dtml-tree tag. I'm currently working on the
f2w project which is a zope based helpdesk app hosted on SourceForge.
And I'm in the process of testing a shipload of zsql methods so they
will run against Oracle. This recipe displays all of the zsql methods
in a tree structure with links that open the method for editing in a new
window.


Source (Text):
<dtml-comment>
Create a dtml method called sql_doc, this is almost identical to
pups code with a couple of changes. You will want to replace the
string YOUR_FOLDER_HERE with the actual name of the top level zope
folder that hold your zsql.
</dtml-comment>

<dtml-in "ZopeFind(restrictedTraverse(['YOUR_FOLDER_NAME']),obj_ids=[newid], obj_metatypes=['Z SQL Method'], search_sub=1)">
  <h2>&dtml.-newid; (&dtml.-title_or_id;)</h2>
  <p><i><a href="<dtml-var absolute_url>/manage" target="_new"><dtml-var absolute_url></a></i></p>
  <blockquote><pre><dtml-var "template"></pre></blockquote>
  <b>Max Rows:</b> <dtml-var "max_rows_"> /
  <b>Max Cache:</b> <dtml-var "max_cache_"> /
  <b>Cache Time:</b> <dtml-var  "cache_time_"> /
  <b>Class:</b> <dtml-var "class_name_"> /
  <b>Class File:</b> <dtml-var "class_file_"> /
  <b>Direct:</b> <dtml-var "allow_simple_one_argument_traversal">
</dtml-in>

<dtml-comment>
Then create another dtml method called sql_map with the following
code. Notice that sql_doc is hardcoded to reference the above method,
change to reference what ever you called the first method.
</dtml-comment>

<dtml-var standard_html_header>

<dtml-tree branches_expr="objectValues(['Folder', 'Z SQL Method'])" nowrap=1 sort=id>
    <dtml-if expr="meta_type == 'Folder'">
         <IMG SRC="<dtml-var SCRIPT_NAME>/<dtml-var icon>"><dtml-var title_or_id>
      <dtml-else>
         <IMG SRC="<dtml-var SCRIPT_NAME>/<dtml-var icon>">
         <A HREF="<dtml-var absolute_url>/sql_doc?newid=<dtml-var id>"><dtml-var id> (<dtml-var title>)</a>
   </dtml-if>
</dtml-tree>

<dtml-var standard_html_footer>

Explanation:
The dtml-method "sql_map" uses the dtml-tree tag to cascade down and display
all of your zsql methods in there natural hiarchy. It also provides a link
to the dtml-method "sql_doc" which will display the contents of the zsql
and create a link using absolute_url/manage. I've also added the "target="_new"
clause that I've found to be helpful when sifting through 100's of zsql methods.



Comments:

No Comments