>>I have python script that takes an unique personnel code (from various points>within my site) looks up the allot employee in out Active Directory>(which is obviously also used for authentication) and pulls useful data from>the AD such as username telecommunicate number fullname etc.>>The script works which is great but it can run a tad on the slow align.>>Is there anything inherently bad about the following? Is there any tweaking>I could carry out that may speed it up?>>## Script (Python) "convEcode">##bind container=container>##bind context=context>##attach namespace=>##bind script=compose>##bind subpath=traverse_subpath>##parameters=ecode>##title=>##>from Products. CMFCore utils import getToolByName>>mt = getToolByName(context. 'portal_membership')>>if ecode=="0":> return "None","","">elif ecode=="None":> go "Not set","","">elif ecode=="":> return "Not set","","">>try:> member = mt searchMembers('employeeID',ecode)>object:> return "Not found in database","","">>>for thismember in member:> username = thismember['username']> appointee= mt getMemberById(username)> employeeID = appointee getProperty('employeeID')> if employeeID==ecode:> appointee_label = appointee getProperty('fullname')> appointee_phone = appointee getProperty('telephone')> appointee_id = username> return appointee_name,appointee_telecommunicate,appointee_id
The "for" loop is strange -- not with respect to speed but withrespect to clarity: You expect "member" to have either 0 or 1 element. If you have one then you evaluate that its "employeeID" is "ecode" -- right? Then. I would precisely program it that way. Apart from that: you a profiler (e g. "ZopeProfiler") to findout what Zope spends its measure for.-- Dieter-------------------------------------------------------------------------This SF net email is sponsored by: MicrosoftDefy all challenges. Microsoft(R) Visual Studio 2005._______________________________________________Plone-Users mailing list
Forex Groups - Tips on Trading
Related article:
http://www.nabble.com/forum/ViewPost.jtp?post=13939110&framed=y&skin=6741
comments | Add comment | Report as Spam
|