[Zope] passing positional paramaters

Ivan Stout aibanhamano at gmail.com
Tue Mar 15 04:01:22 EST 2005


Cliff, you are awesome. Thank you very, very much! 

It turns out that it was actually a separate Z SQL method used in that
same form (To fetch
a summary of previously submitted translations and their associated
rankings for each
line of the document so that users can vote), 
that was causing the trouble. However, since that method queried a
database that DID
NOT have "doclang", I assumed it wasn't the problem . . . however the
method tried to
filter on "doclang" . . . so it WAS the problem. Oh, the irony. .
.Thanks for pointing
me to the right direction! 

Now, all I have to do is add some user tracking/management (one of the
major reason I came to Zope), and I will be ready to unleash this
thing to the wild.

Thanks, again! 

Ivan

On Tue, 15 Mar 2005 08:26:25 +0000, Cliff Ford <Cliff.Ford at ed.ac.uk> wrote:
> The last line of the Tracback tells you the error occurred in the
> ZGadflyDA Product. Note that it is rarely necessary for a User to poke
> around in Products - just look at what your own code is doing with the
> offending attribute (DOCLANG).
> 
> I can reproduce you error by viewing a DTML script that calls a ZSQL
> Method that queries a Gadfly database table - by miss-spelling a
> parameter name. For example, if I declare the ZSQL Arguments as doclang
> and name and make the query:
> 
> select * from Document
> where doclan=<dtml-sqlvar doclang type=string>
> and name=<dtml-sqlvar name type=string>
> 
> Note the miss-spelling (doclan instead of doclang). Then I get exactly
> the traceback you see. But if I use the ZSQL Method Test Tab I get this
> message in the Test result:
> 
> Error, exceptions.NameError: 'DOCLAN': ambiguous or unknown attribute
> 
> Which says mor or less the same thing in this case. That is what I mean
> about testing the ZSQL Method. So you have to check that the arguments
> you are using actually exist as fields in the table you are using (Use
> the Gadfly connection object Browse button).
> 
> Check that you are not accidentally querying a previous table that does
> not have a doclang field.
> 
> Cliff
> 
> Ivan Stout wrote:
> > Dieter, here is the traceback, please help me interpret it.
> >
> > "Traceback (innermost last):
> >   Module ZPublisher.Publish, line 101, in publish
> >   Module ZPublisher.mapply, line 88, in mapply
> >   Module ZPublisher.Publish, line 39, in call_object
> >   Module OFS.DTMLMethod, line 144, in __call__
> >    - <DTMLMethod instance at 0189E410>
> >    - URL: http://tel040302aa.asia.tel.com:8080/ttb/silknet/form_for_translation/manage_main
> >    - Physical Path: /ttb/silknet/form_for_translation
> >   Module DocumentTemplate.DT_String, line 474, in __call__
> >   Module DocumentTemplate.DT_In, line 703, in renderwob
> >   Module DocumentTemplate.DT_In, line 626, in renderwob
> >   Module DocumentTemplate.DT_Util, line 198, in eval
> >    - __traceback_info__: doc
> >   Module <string>, line 1, in <expression>
> >   Module Shared.DC.ZRDB.DA, line 454, in __call__
> >    - <SQL instance at 0189E2F0>
> >   Module Products.ZGadflyDA.db, line 108, in query
> >   Module Products.ZGadflyDA.gadfly.gadfly, line 349, in execute
> >   Module Products.ZGadflyDA.gadfly.sqlsem, line 2641, in relbind
> >   Module Products.ZGadflyDA.gadfly.sqlsem, line 1359, in relbind
> >   Module Products.ZGadflyDA.gadfly.sqlsem, line 398, in relbind
> > NameError: 'DOCLANG': ambiguous or unknown attribute"
> >
> > I have found the actual "sqlsem" but am not too familar with it. It
> > appears to be just checking if paramaters have values or not, but I am
> > probably wrong. . .
> >
> > Cliff, the problem appears to be occuring in just generating the form
> > that will be used for the translation. I have been manually feeding
> > paramaters by calling the translation_form with ?doc=  . . . etc at
> > the end, so I am pretty sure about this.
> >
> > The above Traceback has the path to "form_for_translation", which is
> > the DTML method that  calls the Z SQL method in order to create the
> > form used in the translation. I keep on getting this error:
> >
> > Error Type: NameError
> > Error Value: 'DOCLANG': ambiguous or unknown attribute
> >
> > But DOCLANG is now only used in the Z SQL method. I couldn't find any
> > google reference to "ambiguous or unkown attribute" . . .
> >
> > Thanks,
> >
> > Ivan
> >
> >
> >
> >
> >
> > On Fri, 11 Mar 2005 23:24:09 +0000, Cliff Ford <Cliff.Ford at ed.ac.uk> wrote:
> >
> >>For a simple test I created this query (named BTestSQL and using MySQL,
> >>although that should not matter):
> >>
> >>Arguments doclang name
> >>select * from Document
> >>where doclang=<dtml-sqlvar doclang type=string>
> >>and name=<dtml-sqlvar name type=string>
> >>
> >>and this DTML Method:
> >>
> >><dtml-var standard_html_header>
> >><p>Start of output</p>
> >><dtml-if name><dtml-if doclang>
> >><dtml-in BTestZSQL>
> >><a href="AnotherPage?SerialNo=<dtml-var SerialNo>"><dtml-var SerialNo>:
> >><dtml-var content></a> <br>
> >></dtml-in>
> >></dtml-if></dtml-if>
> >><p>End of output</p>
> >><a href="<dtml-var getId>?name=Cliff&doclang=English">Test</a>
> >><dtml-var standard_html_footer>
> >>
> >>Notice that if the parameters are being passed to the DTML Method you
> >>don't need to put them in the call to the query. OK, so viewing the DTML
> >>method gives you a link with some default parameters. Clicking the link
> >>gives you a list of matching records, each as a link to another form to
> >>do the translation - using a record no.
> >>
> >>It is not clear from your previous posts whether you sequence is
> >>breaking down when generating the list of objects to be translated, or
> >>at the translations stage.
> >>
> >>In addition to checking the Error Log to find which line of which object
> >>triggers the error you should test the ZSQL Method. Database errors can
> >>sometimes cause misleading errors elsewhere.
> >>
> >>HTH
> >>
> >>Cliff
> >>
> >>Ivan Stout wrote:
> >>
> >>>Cliff,
> >>>
> >>>Thanks, but I am still having trouble (even after changing variable
> >>>names, cases) . . . let me explain more what I am trying to do.
> >>>
> >>>1) I have a table called Document (doclang, ordering, content,
> >>>submitdate, name, submitter)
> >>>
> >>>2) A document (say "GPL") gets broken down and inserted into the
> >>>Document table, one sentence at a time.
> >>>
> >>>3) A DTML Method uses a Z SQL method to create a list of what
> >>>documents are in Document and creates URLs to form_for_translation
> >>>(DTML Method) with "?name=<dtml-var doclang>&doclang=<dtml-var
> >>>doclang>" added on the end. (Note: Is there a better way to create a
> >>>list of links that passes paramaters to a DTML method when clicked?)
> >>>
> >>>4) When a link is clicked the 2 paramaters get passed to
> >>>form_for_translation, which passes them to a Z SQL method that queries
> >>>the Document table, allowing form_for_translation to create a form
> >>>that displays each sentece.
> >>>
> >>>This all worked when I was only passing one paramater ("name"), but
> >>>being able to keep track documents in different languages (with
> >>>"doclang") would be a great feature. However, adding doclang causes
> >>>the "ambigous" error . . .
> >>>
> >>>
> >>>On Fri, 11 Mar 2005 08:26:19 +0000, Cliff Ford <Cliff.Ford at ed.ac.uk> wrote:
> >>>
> >>>
> >>>>In the call to the ZSQL Method, in doclang=doclang the first doclang is
> >>>>the name of the variable declared in the ZSQL method and the second
> >>>>doclang is the content of the variable with that name in the DTML
> >>>>Method. So if you put the second doclang in quotes you pas the string
> >>>>'doclang' rather than the content of the doclang variable. That explains
> >>>>why the latter does not cause an error but returns no results. It is
> >>>>often less confusing to use different names for the argument name and
> >>>>value, for example DocLangField=testLanguage (or docLangField='English').
> >>>>
> >>>>The error value you have quoted (Error Value: 'DOCLANG':) suggests the
> >>>>problem may be case sensitivity. Check that the case of the Database
> >>>>Field that you are testing matches the case of the name you are passing
> >>>>to the query. One gotcha to be aware of is that some databases accept
> >>>>field names in any case but return field names in upper case. For
> >>>>example, you may be able to do this:
> >>>>
> >>>>select * from table where doclang is not null
> >>>>
> >>>>but find that the return field name is DOCLANG. Not sure if this is
> >>>>relevant in this case.
> >>>>
> >>>>Cliff
> >>>>
> >>>>Ivan Stout wrote:
> >>>>
> >>>>
> >>>>>Dieter,
> >>>>>
> >>>>>Thanks, it is a Z SQL method . . . I will get rid of the positional
> >>>>>place holders.
> >>>>>
> >>>>>Cliff,
> >>>>>
> >>>>>Thanks for the response.
> >>>>>
> >>>>>I did the following:
> >>>>>
> >>>>>DTML METHOD file:
> >>>>>
> >>>>><html>
> >>>>><dtml-var name><br>
> >>>>><dtml-var doclang>
> >>>>><form action="parsegettranslation.py" method="get">
> >>>>><dtml-in expr="gettransdoc(name=name,doclang=doclang)">  #changed here
> >>>>><br>
> >>>>><dtml-var ordering> <dtml-var content>
> >>>>>
> >>>>>gettransdoc Z SQL Method file:
> >>>>>
> >>>>>(ARGUMENTS:name doclang)
> >>>>>
> >>>>>select *
> >>>>
> >>>>>from document
> >>>>
> >>>>>where name=<dtml-sqlvar name type=string> and doclang=<dtml-sqlvar
> >>>>>doclang type=string>
> >>>>>
> >>>>>This is what I get:
> >>>>>
> >>>>>"Error Type: NameError
> >>>>>Error Value: 'DOCLANG': ambiguous or unknown attribute"
> >>>>>
> >>>>>However, if I add a single quote to the DTML Method, like this:
> >>>>><dtml-in expr="gettransdoc(name='name',doclang='doclang')">
> >>>>>
> >>>>>I do not get an error, but I do not get my query results either . . .
> >>>>>Are the single
> >>>>>quotes getting literally passed to the query or something?
> >>>>>
> >>>>>
> >>>>>
> >>>>>On Thu, 10 Mar 2005 22:11:58 +0000, Cliff Ford <Cliff.Ford at ed.ac.uk> wrote:
> >>>>>
> >>>>>
> >>>>>
> >>>>>>It is not clear to me why you would pass None parameters to a select
> >>>>>>query. Typically your query would have named arguments (name and
> >>>>>>doclang) like this:
> >>>>>>
> >>>>>>select * from yourTable where name=<dtml-sqlvar name type=string>
> >>>>>>and doclang=<dtml-sqlvar doclang type=string>
> >>>>>>
> >>>>>>Leave out the last line if you don't want to select and doclang.
> >>>>>>
> >>>>>>Then call the query like this:
> >>>>>>
> >>>>>><dtml-in expr="gettransdoc(name=name,doclang=doclang)">
> >>>>>><dtml-var ordering> <dtml-var content><br>
> >>>>>></dtml-in>
> >>>>>>
> >>>>>>Cliff
> >>>>>>
> >>>>>>Ivan Stout wrote:
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>>Greetings. I am trying to create an open source communal translation
> >>>>>>>zope product thingy and have run into a snag. I had everything
> >>>>>>>working, but then I realized that I needed to distinguish between what
> >>>>>>>the language that the original document bein translated was in, which
> >>>>>>>required passing an additional paramater to my query to gadfly. Well,
> >>>>>>>this supposedly "broke the paramater chain" requiring me to explicitly
> >>>>>>>add positional paramaters. The problem is, though I no longer get an
> >>>>>>>error, no results are returned from my table. The paramaters are
> >>>>>>>filtering the query, so I believe that my values are getting altered
> >>>>>>>in some way that is causing them to not match anything. Here is what I
> >>>>>>>suspect is causing me trouble . . .(the "----------------->" part):
> >>>>>>>
> >>>>>>><dtml-var name><br>
> >>>>>>><dtml-var doclang>
> >>>>>>><form action="parsegettranslation.py" method="get">
> >>>>>>>-----------> <dtml-in
> >>>>>>>expr="gettransdoc(_.None,_,name='name',doclang='doclang')">
> >>>>>>><br>
> >>>>>>><dtml-var ordering> <dtml-var content>
> >>>>>>><br>
> >>>>>>>
> >>>>>>>Thanks!
> >>>>>>>_______________________________________________
> >>>>>>>Zope maillist  -  Zope at zope.org
> >>>>>>>http://mail.zope.org/mailman/listinfo/zope
> >>>>>>>**   No cross posts or HTML encoding!  **
> >>>>>>>(Related lists -
> >>>>>>>http://mail.zope.org/mailman/listinfo/zope-announce
> >>>>>>>http://mail.zope.org/mailman/listinfo/zope-dev )
> >>>>>>
> >>>>>_______________________________________________
> >>>>>Zope maillist  -  Zope at zope.org
> >>>>>http://mail.zope.org/mailman/listinfo/zope
> >>>>>**   No cross posts or HTML encoding!  **
> >>>>>(Related lists -
> >>>>>http://mail.zope.org/mailman/listinfo/zope-announce
> >>>>>http://mail.zope.org/mailman/listinfo/zope-dev )
> >>>>
> >>>>_______________________________________________
> >>>>Zope maillist  -  Zope at zope.org
> >>>>http://mail.zope.org/mailman/listinfo/zope
> >>>>**   No cross posts or HTML encoding!  **
> >>>>(Related lists -
> >>>>http://mail.zope.org/mailman/listinfo/zope-announce
> >>>>http://mail.zope.org/mailman/listinfo/zope-dev )
> >>>>
> >>>
> >>>_______________________________________________
> >>>Zope maillist  -  Zope at zope.org
> >>>http://mail.zope.org/mailman/listinfo/zope
> >>>**   No cross posts or HTML encoding!  **
> >>>(Related lists -
> >>> http://mail.zope.org/mailman/listinfo/zope-announce
> >>> http://mail.zope.org/mailman/listinfo/zope-dev )
> >>
> > _______________________________________________
> > Zope maillist  -  Zope at zope.org
> > http://mail.zope.org/mailman/listinfo/zope
> > **   No cross posts or HTML encoding!  **
> > (Related lists -
> >  http://mail.zope.org/mailman/listinfo/zope-announce
> >  http://mail.zope.org/mailman/listinfo/zope-dev )
>


More information about the Zope mailing list