I'm using xmlrpc to access some back end functionality for a webware project I'm writing. All of my pages use the same xmlrpclib.ServerProxy instance to make the xmlrpc calls. When I try to set that site-wide variable in my site page's __init__ function, it doesn't work. But when I put it into the awake, it does work (code below). I know that the init is only called once, and the awake is called for every request. But I do set other variables (debug constant, other static variables) in the init, and they work.

The easy answer is "it works in awake, just put it there." Setting up the connection for every page request slows down response time. I'd like to be able to keep the response snappy as much as possible.

What is your experience with init vs awake? Why won't setting the xmlrpc server proxy in init work?

Example code:
class SitePage(Page): # Page is WebKit.Page
def __init__(self):
Page.__init__(self)
self.__debug = MyConfigFile.debug
#self.setLogicServer(MyConfigFile.logic_location) # does not work here (Webware hangs)
# other code clipped


   def awake(self,trans):
      Page.awake(self,trans)
      self.setLogicServer(MyConfigFile.logic_location) # works here
      # other permissions code clipped

def setLogicServer(self,location):
initial_auth_key = 'xyz123'
self.__logicServer = xmlrpclib.ServerProxy(location,transport=MyTransport(initial_auth_key))
try:
self.__logicServer.init_connection('foo','bar','baz') except BadLoginError, msg:
raise # do something smart



------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click _______________________________________________ Webware-discuss mailing list Webware-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/webware-discuss

Reply via email to