
Hi,
I've made a small program. he aim is to access to a Ldap server and to show details of each user. I have a root page, and a child. When I run my program,I'm unable to display items in the root page because on click(in a button on the root page),the program goes immediately in the child page(instead of displaying items in the root page).I can't locate the problem.is someone could help me?
___________________________________________________________________________ Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger Téléchargez cette version sur http://fr.messenger.yahoo.com

Françoise Maguib wrote:
I've made a small program. he aim is to access to a Ldap server and to show details of each user. I have a root page, and a child. When I run my program,I'm unable to display items in the root page because on click(in a button on the root page),the program goes immediately in the child page(instead of displaying items in the root page).I can't locate the problem.is someone could help me?
My crystal ball is a bit dusty. Maybe you should put the source on the web so we can actually look at the program?

I'm really sorry,
there is the source:
import ldap from twisted.application import internet,service
from nevow import appserver,inevow, loaders, util,compy,rend, tags as T, url from nevow.url import here from nevow.tags import *
from formless import annotate from formless import webform
mydata=[]
def findDetails(args): total=len(mydata) myerror=['','',''] ok=False i=0 while(not(ok) and i<total): if mydata[i][0]==args: ok=True indice=i else: i+=1 if ok: return mydata[indice] else: return myerror
def doQuery(args): try: l=ldap.open("x,name): 172.29.160.70") username="" password="" l.simple_bind_s(username,password) l.protocol_version=ldap.VERSION3 except ldap.LDAPError,e: print e base="o=gouv,c=fr" scope=ldap.SCOPE_SUBTREE retrieve_attributes=None filter="uid="+args count = 0 result_set=[]
try:
ldap_result_id=l.search(base,scope,filter,retrieve_attributes)
while 1:
result_type,result_data=l.result(ldap_result_id,0)
if(result_data==[]): break else: if result_type==ldap.RES_SEARCH_ENTRY:
result_set.append(result_data) if len(result_set)==0: return
for i in range(len(result_set)):
for entry in result_set[i]: try: mydetail=[]
mydetail.append(entry[1]['uid'][0])
mydetail.append(entry[1]['cn'][0])
mydetail.append(entry[1]['mail'][0])
mydata.append(mydetail) mydetail.remove #count=count+1 except: pass
except ldap.LDAPError,e: print e
return mydata
class IItemForChange(annotate.TypedInterface): def setSsa(self,ssa=annotate.String(label="Score Spam Assassin")): pass setSsa=annotate.autocallable(setSsa)
class ChildPage(rend.Page):
__implements__=IItemForChange,rend.Page.__implements__ addSlash=True
def __init__(self,name): rend.Page.__init__(self) self.name=name
def setSsa(self,ssa): valeur=ssa
def render_viewSelector(self,context,data): args=inevow.IRequest(context).args view=args.get('view',['view'])[0] if view=='view': selector ="View| ",a(href=here.add('view','edit'))["Edit"] editor ='' else:
selector=a(href=here.add('view','view'))["View"],"| Edit" editor=context.onePattern('edit')() viewer=context.onePattern('view')() return selector,viewer,editor
def render_itemDetail(self,context,data): thedetails=findDetails(self.name) return h2["Name:",thedetails[1]],h2["Email:",thedetails[2]]
docFactory= loaders.stan( T.html[ T.body[ T.p[a(href=here.parent())["UP"]], T.div(render=render_viewSelector)[
T.p(pattern="edit")[webform.renderForms()],
T.p(pattern="view")[render_itemDetail] ] ] ] )
class IFindUser(annotate.TypedInterface): def findUser(self,user=annotate.String()): pass findUser=annotate.autocallable(findUser)
class FatherPage(rend.Page): __implements__ =IFindUser,rend.Page.__implements__ addSlash=True
def __init__(self): rend.Page.__init__(self) self.currentuser=""
def findUser(self,user):
doQuery(user)
def data_queryLdap(self,context,data):
return doQuery(self.currentuser)
def render_row(self,context,data):
theuser=data return context.tag[ a(href=theuser[0])[theuser[0]] ]
docFactory=loaders.stan( T.html[ T.body[ T.h1["Welcome,user"],
T.ul(data=directive("queryLdap"),render=directive("sequence"))[
T.li(pattern="item",render=render_row) ], webform.renderForms() ] ] )
def childFactory(self,ctx,name): try: return ChildPage(name) except ValueError: pass
application=service.Application('monform2') webserver=internet.TCPServer(8080,appserver.NevowSite(FatherPage())) webserver.setServiceParent(application)
-- Tommi Virtanen tv@twistedmatrix.com a écrit :
Françoise Maguib wrote:
I've made a small program. he aim is to access to
a
Ldap server and to show details of each user. I
have a
root page, and a child. When I run my program,I'm unable to display items in the root page because
on
click(in a button on the root page),the program
goes
immediately in the child page(instead of
displaying
items in the root page).I can't locate the
problem.is
someone could help me?
My crystal ball is a bit dusty. Maybe you should put the source on the web so we can actually look at the program?
http://www.catb.org/~esr/faqs/smart-questions.html
Twisted-web mailing list Twisted-web@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web
___________________________________________________________________________ Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger Téléchargez cette version sur http://fr.messenger.yahoo.com
participants (2)
-
Françoise Maguib
-
Tommi Virtanen