Re: [Zope] querying status in zsql
Rik Hoekstra writes: > A short explanation: sql queries return a result object (so does ZCatalog > btw), which you can't address directly in DTML (or at least I wouldn't know > how ;-) If it the result object is empty it won't have a (sequence) start > in a dtml-in. This is the same code SearchInterfaces uses for returning a > 'this query has no results'. "Result" objects behave like sequences. You can ask for their length ("_.len") and access the elements by subscription("[i]"). Of cause, you can use them in "dtml-in". Dieter ___ Zope maillist - [EMAIL PROTECTED] 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 )
Re: [Zope] querying status in zsql
> Thanks for that... Although Im not terribly sure what the magic behind the > sequence-start is, but it works very well. > A short explanation: sql queries return a result object (so does ZCatalog btw), which you can't address directly in DTML (or at least I wouldn't know how ;-) If it the result object is empty it won't have a (sequence) start in a dtml-in. This is the same code SearchInterfaces uses for returning a 'this query has no results'. Rik ___ Zope maillist - [EMAIL PROTECTED] 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 )
Re: [Zope] querying status in zsql
Thanks for that... Although Im not terribly sure what the magic behind the sequence-start is, but it works very well. Cheers, -- Paz Oratrix Development BV http://www.oratrix.com GRiNS SMIL Editor - Rik Hoekstra wrote: > > > > I have a processing script that takes emails and puts them into a table. > > I bring up a table for confirmation and then submit the whole thing by a > > iterative item:records zsql method. > > > > My problem is that the table requires a unique primary key and quite > > regularly there duplicates. So ofcourse it falls over with the expected > > error. I have tried in the zsql method encapsulating the sql with a > > and then at the bottom of the zsql > > loop I commit so make sure the second time around, the data is checked. > > This does not seem to work. > > > > So what im left with wondering is, if I can query in the zsql method: > > if error, then exit or go somewhere else > > > > Is this possible? > > yes, this is possible. If I understand your question at least. BTW This is > untested, but I have used something similar before > > mailid is the input field/variable for your method > > > (if this is another zsql > method) > >skip or do something else > > upload your email. You may want to call another Zsql method > for this > > > > > > sorry to be very vague. The conundrum is the fact that > > the zsql method it an item loop in its own, so i cannot seem to use an > > if statement because it doesnt iterate by the normal route > > > > Any advice? > > hth > > Rik > > ___ > Zope maillist - [EMAIL PROTECTED] > 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 ) ___ Zope maillist - [EMAIL PROTECTED] 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 )
Re: [Zope] querying status in zsql
> > I have a processing script that takes emails and puts them into a table. > I bring up a table for confirmation and then submit the whole thing by a > iterative item:records zsql method. > > My problem is that the table requires a unique primary key and quite > regularly there duplicates. So ofcourse it falls over with the expected > error. I have tried in the zsql method encapsulating the sql with a > and then at the bottom of the zsql > loop I commit so make sure the second time around, the data is checked. > This does not seem to work. > > So what im left with wondering is, if I can query in the zsql method: > if error, then exit or go somewhere else > > Is this possible? yes, this is possible. If I understand your question at least. BTW This is untested, but I have used something similar before mailid is the input field/variable for your method (if this is another zsql method) skip or do something else upload your email. You may want to call another Zsql method for this > sorry to be very vague. The conundrum is the fact that > the zsql method it an item loop in its own, so i cannot seem to use an > if statement because it doesnt iterate by the normal route > > Any advice? hth Rik ___ Zope maillist - [EMAIL PROTECTED] 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 )