On 10/10/2013 11:52 AM, Jiri Zupka wrote:
> Hi Chris,
> in attachment is proposal for decorator version of propcan as we talked
> before.
> From the line 48 is decorator implementation.
> pproperty is compatible with python 2.4.3 which is in rhel 5.
> When later version of the python is used it is be possible use build-in
> property.
> Please take a look a let me know what you mean about this implementation.
>
> only problem which I could see is the need to define wildcard slots _x
> instead of x.
> Example:
> class D(PropCan, CopySlots):
> __slots__ = ['_x', 'y']
>
> @pproperty
> def x(self):
> """ aaaa """
> print "Get"
> return self._x
>
> @x.setter
> def x(self, value):
> print "Set"
> self._x = value
>
> @x.deleter
> def x(self):
> del self._x
>
> regards,
> Jiří Župka
>
Woops, sorry I didn't notice this, I was looking for a pull-request.
TBH, I really don't know much about writing decorators, but I'll try to
understand...
Hmm, ahh, is this a kind of back-port of how property-decorators work in
2.6?
---
I'm not sure the '_x' is actually needed since PropCan itself is a
dict-subclass, couldn't we replace the '_x' reference with a
self.__dict_get__(whatever)?
---
Not sure, but this could present a problem:
class Propcan(object):
__slots__ = ('__doc__', "fset", "fget", "fdel")
There are some users (like Virsh class) that are sometimes passed around
as dictionaries. If the interface itself is exposed at all in
__slots__, doesn't that mean it could get passed around as well?
Couldn't that lead to operation-order problems with the referant and
referer?
---
class PropCan(object):
*head scratch* I think we need different naming so 'Propcan' is
distinguished from 'PropCan' more.
---
Hmmm, this seems like a really big change. While it seems to work, I'm
nervous about how it will play with all the existing code. It may turn
out to be much more work than fixing our first attempt.
Have you looked at what the problem was? I though it was just a simple
typo '__all_slots' vs '__all_slots__', no? Was it a big
gooie-hairry-hairball?
--
Chris Evich, RHCA, RHCE, RHCDS, RHCSS
Quality Assurance Engineer
e-mail: cevich + `@' + redhat.com o: 1-888-RED-HAT1 x44214
_______________________________________________
Virt-test-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/virt-test-devel