[wxpython-dev] Possible to derive from GC?

wxPython developer mailing list, post #661
---Robin Dunn
----Nitro
-----Nitro
-----Robin Dunn
------Nitro
-------Robin Dunn
--------Nitro
Author:
Date:
Subject:
 Nitro
 2008-05-30 01:07:14
 [wxpython-dev] Possible to derive from GC?
Hello,

I've send this message yesterday, but it seems it did not get through,
trying to sending it again.

1) Is it possible to derive my own class from wx.GraphicsContext or should
I rather create a GC by itself and then delegate to it?

2) wx.lib.pubsub seems to have a bug. If I change the code at line 860
class Foo2: to class Foo2(object): then the test breaks, because
_paramMinCount does not work anymore. Is there any reason to use if tests
in the _paramMinCount function? This is the code:

if type(callableObject) is InstanceType:
min, d = _paramMinCountFunc(callableObject.__call__.im_func)
return min-1, d
elif ismethod(callableObject):
min, d = _paramMinCountFunc(callableObject.im_func)
return min-1, d
elif isfunction(callableObject):
return _paramMinCountFunc(callableObject)
else:
raise 'Cannot determine type of callable: '+repr(callableObject)

I've rewritten it to the following code which passes the tests, also with
new-style classes.

try:
func = callableObject.__call__.im_func
except AttributeError:
try:
func = callableObject.im_func
except AttributeError:
try:
return _paramMinCountFunc(callableObject)
except exc:
raise 'Cannot determine type of callable: %s' %
repr(callableObject)
else:
min, d = _paramMinCountFunc(func)
return min-1, d
else:
min, d = _paramMinCountFunc(func)
return min-1, d

This code looks a bit clumsier than the original one. I don't see a much
better way right now though.

3) The pubsub question leads me to another question: How to you want to
handle SVN access? Should I create a branch which will be merged at the
end of the project?
And how should I deal with patches/fixes which are not related to
FloatCanvas (like the one to pubsub above)? Send in a patch on this
mailing list and somebody reviews and accepts it?


-Matthias
_______________________________________________
wxpython-dev mailing list
[email protected]
http://lists.wxwidgets.org/mailman/listinfo/wxpython-dev
Author:
Date:
Subject:
 Robin Dunn
 2008-05-29 18:06:31
 Re: [wxpython-dev] Possible to derive from GC?
Nitro wrote:
> Hello,
>
> I've send this message yesterday, but it seems it did not get through,
> trying to sending it again.
>
> 1) Is it possible to derive my own class from wx.GraphicsContext or
> should I rather create a GC by itself and then delegate to it?

I expect that either would be ok, but past experience I would guess that
the typical approach in this case would be delegation.


>
> 2) wx.lib.pubsub seems to have a bug. If I change the code at line 860
> class Foo2: to class Foo2(object): then the test breaks, because
> _paramMinCount does not work anymore. Is there any reason to use if
> tests in the _paramMinCount function? This is the code:
>
> if type(callableObject) is InstanceType:
> min, d = _paramMinCountFunc(callableObject.__call__.im_func)
> return min-1, d
> elif ismethod(callableObject):
> min, d = _paramMinCountFunc(callableObject.im_func)
> return min-1, d
> elif isfunction(callableObject):
> return _paramMinCountFunc(callableObject)
> else:
> raise 'Cannot determine type of callable: '+repr(callableObject)
>
> I've rewritten it to the following code which passes the tests, also
> with new-style classes.
>
> try:
> func = callableObject.__call__.im_func
> except AttributeError:
> try:
> func = callableObject.im_func
> except AttributeError:
> try:
> return _paramMinCountFunc(callableObject)
> except exc:
> raise 'Cannot determine type of callable: %s' %
> repr(callableObject)
> else:
> min, d = _paramMinCountFunc(func)
> return min-1, d
> else:
> min, d = _paramMinCountFunc(func)
> return min-1, d
>
> This code looks a bit clumsier than the original one. I don't see a much
> better way right now though.

It would be nice to not have to duplicate the two else clauses at the end.


>
> 3) The pubsub question leads me to another question: How to you want to
> handle SVN access? Should I create a branch which will be merged at the
> end of the project?

Yes. I think you'll need it anyway so you can easily extract out the
changes you've made so you can turn them in to google at the end of the
summer.


> And how should I deal with patches/fixes which are not related to
> FloatCanvas (like the one to pubsub above)? Send in a patch on this
> mailing list and somebody reviews and accepts it?

Yes, or submit a ticket at trac.wxwidgets.org.

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

_______________________________________________
wxpython-dev mailing list
[email protected]
http://lists.wxwidgets.org/mailman/listinfo/wxpython-dev
Author:
Date:
Subject:
 Nitro
 2008-05-30 03:16:35
 Re: [wxpython-dev] Possible to derive from GC?
Am 30.05.2008, 03:06 Uhr, schrieb Robin Dunn <[email protected]>:

> It would be nice to not have to duplicate the two else clauses at the
> end.

Good idea :-)

try:
func = callableObject.__call__.im_func
except AttributeError:
try:
func = callableObject.im_func
except AttributeError:
try:
return _paramMinCountFunc(callableObject)
except exc:
raise 'Cannot determine type of callable: %s' %
repr(callableObject)

min, d = _paramMinCountFunc(func)
return min-1, d


>> FloatCanvas (like the one to pubsub above)? Send in a patch on this
>> mailing list and somebody reviews and accepts it?
>
> Yes, or submit a ticket at trac.wxwidgets.org

Ok, should I submit a ticket for this one so it is not forgotten about?

Thanks for your help,
-Matthias
_______________________________________________
wxpython-dev mailing list
[email protected]
http://lists.wxwidgets.org/mailman/listinfo/wxpython-dev