[Zope-DB] External methods and zope objects

Charlie Clark charlie at egenix.com
Tue Mar 22 07:10:01 EST 2005


On 2005-03-22 at 01:29:07 [+0100], srikanth <srikanth.m at monsterfirst.com> 
wrote:
> just wondering  if external methods too return zope objects. I will try to 
> be more specific.
> 
> My external method is an python script that access the database and get a 
> recordset for me. It passes back the recordset to the dtml method( as i am 
> using an dtml to call the external method). When i try to display the 
> things. The only thing i was able to do was display the whole record set 
> using an <dtml-var <method-name> .
> i tried with <dtml-in and <dtml-call but both of them also did the same 
> thing,  so i just wonder if the external method is passing back an Result 
> Object or just a string.
> 
> Is there any way that i can call a script from another script. I mean if 
> its passing back a string, i can use another script to format the string 
> into items which would be helpfull to dispaly in a table format.

Dear Srikanth,

you really should spend some time reading the Zope book and looking at the 
examples then you wouldn't need to ask these questions.

ExternalMethods can return Zope objects if they access Zope services. This 
is the case when you use the mxODBCZopeDA as an ExternalMethod. Otherwise 
you will need to convert the record set to a Zope Results objects in order 
to be able to use it as one. But you will be able to use Python objects such 
as a result set within Zope quite easily.

<div tal:repeat="item here/myExternalMethod" tal:content="item/1">
</div>

Access by position rather than name should work.

As I said yesterday - DTML is deprecated when it comes to rendering content. 
You should look at ZPT instead.

It is very easy to call one Script from another:

result = context.OtherScript()

Formatting is usually done in the ZPT with occasional calls to Scripts where 
special formatting beyond what can be achieved in a Python Expresssion may 
be required.

Charlie
-- 
Charlie Clark
eGenix.com

Professional Python Services directly from the Source
 >>> Python/Zope Consulting and Support ...        http://www.egenix.com/
 >>> mxODBC.Zope.Database.Adapter ...             http://zope.egenix.com/
 >>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/
________________________________________________________________________

::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! ::::


More information about the Zope-DB mailing list