chromecow
Visitor
|
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: | error: uncaptured python exception, closing 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.
|