[Zope] Fetching data from external methods

2000-07-12 Thread Jarkko Veijalainen


Hi!

I've been trying almost two weeks with this problem. I have read 'tons' on
zope documentation and mailing lists. 

I have this dtml form, which submits two values to external method. External
method searches LDAP directory with submitted values and returns an
object(class) with 5-30 values. I know only how to return plain text to Zope
(return obj.__dict__ or  return obj.value1). How i return those values in
zope and embed those values into dtml file.

I have some kind of clue, how i want to do this (or do i?):
can i make Zclass and return values into that and call Zclass
variables in dtml?  

in fact only problem here is how i return values from external
method like obj.value1 , obj.value2 into zope and use them in
dtml or/and in Zclass instances.

Please, somobody save my nerves and help me figure solution with this
problem.

JarkkoV

___
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] Fetching data from external methods

2000-07-12 Thread Chris Withers

Jarkko Veijalainen wrote:
 in fact only problem here is how i return values from external
 method like obj.value1 , obj.value2 into zope and use them in
 dtml or/and in Zclass instances.

in external method:

return (obj1, obj2,)

in DTML:

dtml-in external_method(your,params)
  dtml-var value1
  dtml-var value2
/dtml-in

If you are submitting to your external method from an HTML form, you
will need to return the HTML to be displayed:

def my_external_method(self,param1,param2):
...do stuff...
string = 'HTMLBODY'
string = string + ...render your results here...
string = string + '/BODY/HTML'
return string

HTH,

Chris

___
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] Fetching data from external methods

2000-07-12 Thread Jarkko Veijalainen

sorry but your example did'nt work:

in external method:

   return (obj1, obj2,)

in DTML:

dtml-in external_method(your,params)
  dtml-var value1
  dtml-var value2
/dtml-in

here is my submit forms code to explain my case

form action="LDAPsearch" method=POST ENCTYPE="multipart/form-data"
   cn: br
input name="cn" size="10"br
   objectclass: br
input name="objectclass" size="15"brbr

  input type="SUBMIT" name="send" value=" Search "
/form

LDAPsearch is my external method (object in zope which points to .py module)

My method outputs are:

res = (contains search result using forms input values)
sn = res.sn (one of the values in res-object)
return sn

and i try to embed in dtml like this

dtml-in "LDAPsearch('66','*',REQUEST)"
dtml-var sn
/dtml-in


Zope returns error:
Error Type: InError
Error Value: Strings are not allowed as input to the in tag.

if i try to return 
res.__dict__   in external method

zope returns this kind of error:
Error Type: KeyError
Error Value: 0

this works
dtml-var "LDAPsearch('66','*',REQUEST)"
but it lefs me with two problems
1) how i can input values in LDAPsearch(how i input here)
2) i don't have any control of return value, it returns list like
this
('Ukko', '66', 'oEmail') 

If you are submitting to your external method from an HTML form, you
will need to return the HTML to be
def my_external_method(self,param1,param2):
   ...do stuff...
   string = 'HTMLBODY'
   string = string + ...render your results here...
   string = string + '/BODY/HTML'
   return string

this solution worked, but it's not what i really want to do. I don't want
include return HTML-file in my python script, like in that example. 


___
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] Fetching data from external methods

2000-07-12 Thread Jarkko Veijalainen


FINALY, your code sould look like:


In externalMethod:
return res 
#ENTIRE obj 

DTML code:
dtml-let resDTML="LDAPsearch('66','*',REQUEST)"
dtml-var "resDTML.cn"
dtml-var "resDTML.otherAttributes"
/dtml-let

yeah, thanks a lot, it works, but i have still a liitle problem
this might sound like newbie question ( but i don't really know)

how i can dtml-res with input values like this
dtml-let resDTML="LDAPsearch(myinput,myinput2,REQUEST)"

myinput is data that i can type like search criteria in my
search-form

should i make somekind on handler-DTML? which picks up submitted
datafrom my submitted form and puts them in dtml-let? 

PM

jarkkov

___
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] Fetching data from external methods

2000-07-12 Thread Chris Withers

Jarkko Veijalainen wrote:
 My method outputs are:
 
 res = (contains search result using forms input values)
 sn = res.sn (one of the values in res-object)
 return sn
  ^
  that should be 'return res'

...then the following will work:

 dtml-in "LDAPsearch('66','*',REQUEST)"
 dtml-var sn
 /dtml-in

 this works
 dtml-var "LDAPsearch('66','*',REQUEST)"

...because that displays sn, which is what you're returning!

 1) how i can input values in LDAPsearch(how i input here)

Don't understand what you want here...

 2) i don't have any control of return value, it returns list like
 this
 ('Ukko', '66', 'oEmail')

you should be able to dtml-in over whatever is returning that...

Chris

___
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] R: [Zope] Fetching data from external methods

2000-07-12 Thread Marcel Preda

 
 how i can dtml-res with input values like this
 dtml-let resDTML="LDAPsearch(myinput,myinput2,REQUEST)"
 
 myinput is data that i can type like search criteria in my
 search-form
 
 should i make somekind on handler-DTML? which picks up submitted
 data from my submitted form and puts them in dtml-let? 

Nothing to do, will work...

As an advice , 
from time to time, try:
dtml-var REQUEST
You will see a lot of interesting things
[maybe you know that]

PM


___
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 )