471,348 Members | 1,428 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,348 software developers and data experts.

Dispatching a method using PyobjC Selectors/Methods

I am writing a SIMBL plugin for Mail.app, so far it loads and the
correct method has been swizzled. However, i would like to call the
original method and that is where the problem lies.

If you could see the code(below), in console.app, i get the following
error because of old(x)
2007-06-26 03:42:04.053 Mail[2600] *** NSRunLoop ignoring exception
'exceptions.TypeError: 'int' object is not callable' that raised
during posting of delayed perform with target 5bd1b10 and selector

#saved as MailDump.py
import objc
from Foundation import *
from AppKit import *
WebMessageEditor = objc.lookUpClass('WebMessageEditor')
swizzled = {}
def swizzle(cls, SEL, func):
oldIMP = cls.instanceMethodForSelector_(SEL)
oldMethod = objc.selector(oldIMP.__call__,
selector=oldIMP.selector, signature=oldIMP.signature)
newMethod = objc.selector(func, selector=oldIMP.selector,
objc.classAddMethod(cls, 'OLD'+SEL, oldMethod)
objc.classAddMethod(cls, SEL, newMethod)
swizzled[(cls, SEL, func)] = (oldMethod, newMethod, oldIMP)
def updateContentsToShowSignature_(self,x):
class MWM(NSObject):
plugin = None # We will retain a pointer to the plugin to prevent
it being garbage-collected
def sharedInstance(cls): # not strictly necessary, but we only
need one instance of our object
if not cls.plugin:
cls.plugin = cls.alloc().init()
return cls.plugin

def initialize(cls):
'updateContentsToShowSignature:', updateContentsToShowSignature_)
# from distutils.core import setup
# import py2app
# plist = dict(
# NSPrincipalClass='MWM',
# CFBundleName='MWM',
# SIMBLTargetApplications=[dict(BundleIdentifier='com.apple.mail',
MinBundleVersion='000', MaxBundleVersion='999920')],
# )

# setup(
# plugin=['MailDump.py'],
# options=dict(py2app=dict(
# extension='.bundle',
# plist=plist,
# )),
# )
#Run the following
#python2.4 setup.py py2app -A
#and copy the dist/MailDump.bundle to ~/Library/Application Support/

Jun 26 '07 #1
0 1107

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Sarah Mount | last post: by
3 posts views Thread by Kenneth McDonald | last post: by
1 post views Thread by Terry | last post: by
1 post views Thread by Tony Benham | last post: by
reply views Thread by Edson Tadeu | last post: by
3 posts views Thread by Hallvard B Furuseth | last post: by
6 posts views Thread by =?ISO-8859-1?Q?Une_B=E9vue?= | last post: by
reply views Thread by Horace Enea | last post: by
1 post views Thread by flyfree | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.