Skip to content

Commit

Permalink
cfreactor into twisted internet (issue164 / issue312)
Browse files Browse the repository at this point in the history
git-svn-id: svn://svn.twistedmatrix.com/svn/Twisted/trunk@8905 bbbe8e31-12d6-0310-92fd-ac37d47ddeeb
  • Loading branch information
etrepum committed Oct 13, 2003
1 parent 812b986 commit d9d1fd5
Show file tree
Hide file tree
Showing 48 changed files with 1,945 additions and 905 deletions.
20 changes: 20 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
2003-10-13 Bob Ippolito <bob@redivi.com>

* doc/examples/cocoaDemo:
Removed, replaced by doc/examples/Cocoa cfreactor demos.

* doc/examples/Cocoa:
Moved from sandbox/etrepum/examples/PyObjC, cleaned up.

* twisted/internet/cfsupport, twisted/internet/cfreactor.py:
Moved from sandbox/etrepum, cleaned up.

* twisted/application/app.py:
Added 'cf' -> twisted.internet.cfreactor to reactorTypes

* setup.py:
sys.platform=='darwin' - build cfsupport, do not build cReactor.

* INSTALL:
Changed URL of pimp repository to shorter version.

2003-10-12 Jp Calderone <exarkun@twistedmatrix.com>

* bin/tktwistd, twisted/scripts/tktwistd.py, doc/man/tktwistd.1:
Expand Down
2 changes: 1 addition & 1 deletion INSTALL
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Installation

Mac OS X packages and dependences can be obtained from:

http://undefined.org/python/pimp/darwin-6.6-Power_Macintosh.html
http://undefined.org/python/pimp/

Win32 EXEs are available from http://twisted.sf.net, as well as tarballs
for other platforms. As with other Python packages, the standard way of
Expand Down
4 changes: 4 additions & 0 deletions doc/examples/Cocoa/SimpleWebClient/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
To run the demo:

python bundlebuilder.py build
open build/Twistzilla.app
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
# Twisted, the Framework of Your Internet
# Copyright (C) 2003 Matthew W. Lefkowitz
#
# MyAppDelegate.py
# cocoaDemo
# This library is free software; you can redistribute it and/or
# modify it under the terms of version 2.1 of the GNU Lesser General Public
# License as published by the Free Software Foundation.
#
# Created by Bob Ippolito on Fri Jan 17 2003.
# Copyright (c) 2003 __MyCompanyName__. All rights reserved.
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

# import needed classes/functions from Foundation
from Foundation import NSObject, NSLog, NSTimer, NSMutableString, NSRunLoop

# import Nib loading functionality from AppKit
from PyObjCTools import NibClassBuilder, AppHelper
from PyObjCTools.NibClassBuilder import AutoBaseClass

import twisted.internet.cfreactor
reactor = twisted.internet.cfreactor.install()
Expand All @@ -36,7 +41,7 @@ def connectionMade(self):
def handleResponse(self, data):
self.delegate.gotResponse_(data)

class MyAppDelegate(AutoBaseClass):
class MyAppDelegate(NibClassBuilder.AutoBaseClass):
def gotResponse_(self, html):
s = self.resultTextField.textStorage()
s.replaceCharactersInRange_withString_((0, s.length()), html)
Expand All @@ -53,12 +58,12 @@ def doTwistzillaFetch_(self, sender):
else:
host, port = u[1][:pos], int(u[1][pos+1:])
if u[2] == '':
file = '/'
fname = '/'
else:
file = u[2]
fname = u[2]
host = host.encode('utf8')
file = file.encode('utf8')
protocol.ClientCreator(reactor, TwistzillaClient, self, (host, port, file)).connectTCP(host, port).addErrback(lambda f:self.gotResponse_(f.getBriefTraceback()))
fname = fname.encode('utf8')
protocol.ClientCreator(reactor, TwistzillaClient, self, (host, port, fname)).connectTCP(host, port).addErrback(lambda f:self.gotResponse_(f.getBriefTraceback()))

def applicationDidFinishLaunching_(self, aNotification):
"""
Expand All @@ -67,12 +72,9 @@ def applicationDidFinishLaunching_(self, aNotification):
loop.
"""
self.messageTextField.setStringValue_("http://www.twistedmatrix.com/")
# get current CFRunLoop
cfr = NSRunLoop.currentRunLoop().getCFRunLoop()
reactor.run(installSignalHandlers=False, withRunLoop=cfr)
reactor.run(installSignalHandlers=False)

if __name__ == '__main__':
from twisted.python import log
log.startLogging(sys.stdout)
NibClassBuilder.extractClasses('MainMenu.nib')
AppHelper.runEventLoop()
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
from bundlebuilder import buildapp
import glob
from bundlebuilder import buildapp

buildapp(
name = 'Twistzilla',
mainprogram = "Twistzilla.py",
resources = ["English.lproj"],
nibname = "MainMenu",
)
)
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import sys

# import pyobjc
import objc
import Foundation
import AppKit
from PyObjCTools import AppHelper

# import classes required to start application
import WSTApplicationDelegateClass
import WSTConnectionWindowControllerClass

# pass control to the AppKit
sys.exit( AppKit.NSApplicationMain(sys.argv) )
AppHelper.runEventLoop()
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ b.bum
bbum@codefab.com

This application has been modified for Twisted. It demonstrates:
- using Twisted in a Cocoa app
- using Twisted in a Cocoa app with the cfreactor
- how to write responsive single-threaded network applications

To run the demo:
python buildapp.py build
open build/Web\ Services\ Tool.app

bob@redivi.com
File renamed without changes.
File renamed without changes
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

from AppKit import *
from Foundation import *
from PyObjCTools import NibClassBuilder

from objc import IBOutlet
from objc import selector
Expand All @@ -26,7 +27,6 @@
reactor = twisted.internet.cfreactor.install()
from twisted.internet import defer
from twisted.web.xmlrpc import Proxy
#import xmlrpclib

import sys
import types
Expand Down Expand Up @@ -80,7 +80,6 @@ def addToolbarItem(aController, anIdentifier, aLabel, aPaletteLabel,

aController._toolbarItems[anIdentifier] = toolbarItem

from PyObjCTools import NibClassBuilder
NibClassBuilder.extractClasses( "WSTConnection" )

class WSTConnectionWindowController(NibClassBuilder.AutoBaseClass):
Expand Down Expand Up @@ -137,7 +136,7 @@ def awakeFromNib(self):
self.createToolbar()
# Start the CFReactor if it's not already going
if not reactor.running:
reactor.run(withRunLoop=NSRunLoop.currentRunLoop().getCFRunLoop())
reactor.run()

def windowWillClose_(self, aNotification):
"""
Expand Down Expand Up @@ -239,7 +238,7 @@ def toolbar_itemForItemIdentifier_willBeInsertedIntoToolbar_(self,
newItem.setMinSize_( item.minSize() )
newItem.setMaxSize_( item.maxSize() )

return newItem
return newItem

def setStatusTextFieldMessage_(self, aMessage):
"""
Expand Down Expand Up @@ -353,7 +352,7 @@ def fetchMethodSignature(self, ignore, index, aMethod):
% (aMethod , index, len(self._methods))
)
return self._server.callRemote(
self._methodPrefix + 'methodSignature',
self._methodPrefix + 'methodSignature',
aMethod
)

Expand Down
2 changes: 0 additions & 2 deletions doc/examples/cocoaDemo/.cvsignore

This file was deleted.

Binary file removed doc/examples/cocoaDemo/English.lproj/InfoPlist.strings
Binary file not shown.
20 changes: 0 additions & 20 deletions doc/examples/cocoaDemo/English.lproj/MainMenu.nib/info.nib

This file was deleted.

Binary file not shown.
74 changes: 0 additions & 74 deletions doc/examples/cocoaDemo/MyAppDelegate.py

This file was deleted.

19 changes: 0 additions & 19 deletions doc/examples/cocoaDemo/__main__.py

This file was deleted.

Loading

0 comments on commit d9d1fd5

Please sign in to comment.