[Zope] Follow-on to Re: [Zope] dtml-with problems
Scott Anderson
sanderson@ttm.com
Wed, 15 Sep 1999 17:39:12 -0400
With Jeffrey's help I fixed my dtml-with problem.
However, attempting to use the same technique in another Method in the
same Folder is giving me other problems:
Error Type: AttributeError
Error Value: __getitem__
The following is the DTML Method giving the error. It is being called
by a form POST method; the only fields on the form are 1) a hidden field
named 'sReportTypeID' with value 'no' to indicate a new insertion as
opposed to an edit, and 2) a field named sDescription.
tblReportTypeInsertOrUpdate is a SQL Method that inserts/changes the
record referenced by sReportTypeID. If sReportTypeID is 'no', the SQL
Method performs an insert followed by a select, as I am using an
IDENTITY column (monotonically increasing auto-index field).
DTML Method at /Reporting/Admin/editReportType:
<dtml-var standard_html_header>
<dtml-with adminSQL>
<!--guaranteed to return only one row-->
<dtml-in tblReportTypeInsertOrUpdate>
<dtml-call "REQUEST.set('sReportTypeID', reportTypeID)">
</dtml-in>
</dtml-with>
<!-- astute readers will recognize the following from Jeffrey's
solution-->
<dtml-with "_.namespace(renderType='edit', renderID=sReportTypeID)">
<dtml-var renderReportType>
</dtml-with>
<dtml-var standard_html_footer>
The REQUEST.set is intended to pass the new request type ID for use
later in the method. (better ways of doing this...? perhaps do this in
the SQL method instead?)
The form performing the POST:
<!--#var standard_html_header-->
Enter the description of the new report type.
<BR>
<form action="editReportType" method="POST">
<INPUT TYPE="HIDDEN" NAME="sReportTypeID" VALUE="no">
<INPUT TYPE="TEXT" NAME="sDescription" SIZE="50" MAXLENGTH="50"
VALUE="New Report Type">
<BR>
<input type="submit" name="submit" value="Add New Report Type">
<!--#var standard_html_footer-->
Thank you for your patience! If I can get over this hump of
understanding the passing of parameters between pages, I feel that I can
begin to start using ZOPE to its potential.
Regards,
-scott anderson
Jeffrey@digicool.com wrote:
>
> > Hi all,
> >
> > I have a DTML Document that calls a DTML Method:
> >
> > <dtml-var standard_html_header>
> > <dtml-var expr="renderReportType(renderType='edit',
> > renderID=reportTypeIDSearch)">
> > <dtml-var standard_html_footer>
>
> Try:
>
> <dtml-var expr="renderReportType(_,_.None,renderType='edit',
> renderID=reportTypeIDSearch)">
>
> The first two arguments (_,_.None) pass in the namespace (aka, '_') and
> an entity known as the client (here as _.None). The _.None stems from
> very very old behaviour of the underpinnings of DTML Methods.
>
> There are some How-To's on the Zope site that talk about the Namespace,
> which is a critical feature of DTML. Without passing in the _ and
> _.None, the DTML Method that you're calling loses the namespace of the
> DTML Method/Document calling it.
>
> Another alternative would be to do:
>
> <dtml-with expr="_.namespace(renderType='edit',
> renderID=reportTypeIDSearch)">
>
> <dtml-var renderReportType>
> </dtml-with>
>
> (you could also use the dtml-let tag here). The dtml-with tag pushes a
> new level onto the namespace and places values in it, and then renders
> the 'renderReportType' DTML inside of that namespace, and then pops the
> new level of namespace off.
>