Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!
  #1  
Old February 28th, 2004, 06:43 PM
captainn captainn is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 1 captainn User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question How do I sendLine externally with a twisted.basic.LineReceiver?

Hello. I'm trying to get a better grasp of Twisted and Tkinter programming by writing a simple chat program. My server is simple enough and works well, and the client mostly works except for 1 problem:

The client cannot call the basic.LineReceiver class from any other class to sendLine. It can can call any function from the basic.LineReceiever so long as the function does not sendLine.

The error I receive when trying to call sendLine from chatFacory.sendMessage() is this:
in sendLine
return self.transport.write(line + self.delimiter)
AttributeError: 'NoneType' object has no attribute 'write'


The classes I am working with are as follows:

class chatClient(basic.LineReceiver):

def connectionMade(self):
self.sendLine("A new person has entered the room!")

def message(self):
self.sendLine("Bah")

def lineReceived(self, line):
app.text_output.config(state=NORMAL) #enable text_output for insert
app.text_output.insert(END, line +"\n")
app.text_output.config(state=DISABLED)
app.text_input.delete(0, END) #clear text_input
app.text_output.see(END) #move scrollbar to the bottom

def connectionLost(self, reason):
from twisted.internet import reactor
reactor.stop()

class chatFactory(protocol.ClientFactory):
protocol = chatClient

def clientConnectionFailed(self, connector, reason):
print "Connection failed - goodbye!"
reactor.stop()

def clientConnectionLost(self, connector, reason):
print "Connection lost - goodbye!"
reactor.stop()

def sendMessage(self):
c = chatClient()
c.message()


If anyone has run across a similar problem and can offer any advice, I would greatly appreciate it!

Thanks,
Captain N

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > How do I sendLine externally with a twisted.basic.LineReceiver?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway