You don't need frames to view this website. Flash communication server. Flash mx xml socket server.
Home
Main Menu
Home
- - - - - - -
What is Palabre ?
Features
News
FAQ
Forum
DEMO
- - - - - - -
Downloads !
Browse SVN
- - - - - - -
Search
Contact Us
- - - - - - -
Sourceforge Project Page
Python
Links




 
Download Palabre Flash Xml Socket Server DOWNLOAD Download Palabre Flash Xml Socket Server FORUM Download Palabre Flash Xml Socket Server FAQ Download Palabre Flash Xml Socket Server WHAT IS IT
 



Using Palabre ? Coming here for Support ? Please consider making an (even small) donation :)
Palabre Forum  


::post new topic::
Can a module be called from another module? - 2008/04/15 03:11 I'm working on my message pre-processor, and I've run into a bit of trouble trying to get the pre-processor module to talk to other modules.

Here's a simplified version of the message preprocessor module:

Code:

 from palabre import logger,logging from slash import routeSlash class mPre:     # SET UP ALL THE CLASS STUFF HERE     def doNode(self,nodeName,node,client):             if node['text'].startswith("/"):                 #send to Slash Module                 slash.routeSlash(node['attrs'],node['text'])             else:                 nodeName "m"                            client.clientHandleMessage(node['attrs'],node['text'], "m")   



This works fine to determine if the user has sent a message starting with a "/", but when I try to call the module that handles Slash messages, I get this:

Code:

 erroruncaptured python exceptionclosing channel <palabre.palabreClient.PalabreClient connected 'xx.xxx.xxx.xx' at -0xxxxxxx> (exceptions.NameError:global name 'slash' is not defined



The slash module (such as it is), looks like this:

Code:

 from palabre import logger,logging class slash:     def __init__(self,server):         self.server server         self.name "slash"         self.server.registerAction('routeSlash',self.name)         return          def routeSlash(self,nickName,attrs,client):         logger.info("Arrived Slash")                            return



I think I may be missing something fundamental about how modules are set up.
  reply | quote
Re:Can a module be called from another module? - 2008/04/15 05:53 The answer is yes. I just made a silly indentation error.

A trace of the flow shows that server imports client and room, and then imports all the modules.

So for the preprocessing module to call the slash.routeSlash() method, the definition had to be at the top level, and I just had it indented one level.

I popped it back out to the top level, and it works a charm:


Code:

  from palabre import logger,logging class slash:     def __init__(self,server):         self.server server         self.name "slash"         self.server.registerAction('routeSlash',self.name)         return # This used to be indented one level def routeSlash(self,nickName,attrs,client):     logger.info("Arrived Slash")                         return

  reply | quote
Re:Can a module be called from another module? - 2008/04/15 06:52 Hi,

You may also call an instandiated module from another like this :

self.server.modules['OtherModuleName'].AnyMethod()
Célio Conort
Lonesome Palabre developper
  reply | quote
::post new topic::