[Zope] trouble with acquisition
Erik Myllymaki
Erik Myllymaki" <erikm@islandnet.com
Tue, 6 Jun 2000 12:17:32 -0700
Hello,
I am new to OOP and Zope so please forgive me if I am being a chowderhead
;-)
I have a root report folder called "ReportParent". Within this folder, I
have 47 folders called, for simplicity, "report1, report2 ... reportN".
Within each of these folders I have a ZSQL query called "query" that is a
simple select statement.
In the ReportParent folder, I have an external method called columnNames:
#-----------------------------------------------
def columnNames(self):
""" docstring """
fieldnames = []
tempList = []
res=self.query()
columns = res._schema.items()
for (name,value) in columns:
tempList.append((value,name))
tempList.sort()
for name, value in tempList:
fieldnames.append(value)
return fieldnames
-------------------------------------------------
This returns the column names of the batch returned by the "query" ZSQL
Method in each reports1..N folder. In each folder is also an "index_html"
DTML Doc that renders the batch returned from the ZSQL Method:
-------------------------------------------------
<dtml-var standard_html_header>
Created for <dtml-var "REQUEST.AUTHENTICATED_USER.getUserName()"> on
<dtml-var ZopeTime fmt="%d/%m/%Y"> at <dtml-var ZopeTime fmt="%H:%M"> <br>
<p>
<table border="2">
<tr>
<dtml-in columnNames>
<dtml-comment> Click on column header to re-order by that
column!!!!!</dtml-comment>
<td><a href="<dtml-var URL1>?orderby=<dtml-var sequence-item>"><dtml-var
sequence-item></a></td>
</dtml-in>
</tr>
<dtml-in query>
<tr>
<dtml-in sequence-item>
<td align=right><dtml-var sequence-item></td>
</dtml-in>
</tr>
</dtml-in>
</table>
</p>
<dtml-if "REQUEST.AUTHENTICATED_USER.getUserName() == 'root'">
<hr>
<p>
SQL Source:<br><pre>
<dtml-var expr="_.string.replace(query(src__=1),_.chr(0) ,'<hr>')">
</pre></p>
</dtml-if>
<dtml-var standard_html_footer>
--------------------------------------------------------------------
I can call these queries with - www.mysite.net:8080/ReportParent/reportN and
get the desired results.
I have two questions on how I would like to change things:
1. The DTML Doc "index_html" is the same in the case of 45 of the 47 reports
folders. Seems to me I should be able to move the common index_html up to
the ReportParent folder, and just leave the two specialized ones where they
are, in their report? folders and continue to call the reports the same way.
Those that have a local index_html will use that, the others will look up
the hierarchy and find the common one in ReportParent. However, when I do
this and call the reports with the same URL I get:
"Error Type: AttributeError - Error Value: query" ?
Seems the index_html DTML Doc (or columnNames extended Method) can't find
"query" below it. How do I address this properly?
2. How do I pass in the ZSQL Method object to the external method
"columnNames.py"?
I'd like to name the queries what I want and reuse this method anywhere,
without the query having to be named "query". Out of frustration, I named
all the queries with the same name and then addressed "query" explicitly in
the external method, because no matter what I tried, I couldn't get the
cloumnNames methos to accept the ZSQL Method name as a second parameter?!
Thanks for your input,
Erik Myllymaki
erik@pacific-shores.com