Re: Re: Trellis + Python 2.6
"Sergey Schetinin" <[email protected]> Tue, 18 Nov 2008 23:04:36 +0200
| Newsgroups | gmane.comp.python.peak |
|---|---|
| Message-ID | <[email protected]> |
Here's the patch. I also left two more changes in: - cancel the rule if assigned - log undo for new Component cells On Tue, Nov 18, 2008 at 20:23, Sergey Schetinin <[email protected]> wrote: > I've only checked with python 2.5, but it should work with others too, > because it basically only chages where things are imported etc. I'll > send it when I get to my desktop. > > On Tue, Nov 18, 2008 at 18:10, Phillip J. Eby <pje-Wh6+Hckhi6HFNGf7iClzIwC/[email protected]> wrote: >> At 01:25 PM 11/18/2008 +0200, Sergey Schetinin wrote: >>> >>> > Issue 1: >>> > UserList.UserList now has a metaclass, so trellis.List needs to >>> > redefine its metaclass to inherit from it >>> >>> > Issue 2: >>> > trellis.py imports `sets` module which is deprecated and results in a >>> > warning. >>> >>> Issue 3: >>> >>> peak\events\trellis.py:511: DeprecationWarning: object.__new__() takes >>> no parameters >>> return ReadOnlyCell.__new__(cls, rule, value, discrete) >>> >>> >>> If you don't have py2.6 installed, let me know and I'll send the patch >>> with relevant changes. >> >> Does your patch still work with older Pythons? >> >> > > > > -- > Best Regards, > Sergey Schetinin > > http://s3bk.com/ -- S3 Backup > http://word-to-html.com/ -- Word to HTML Converter > -- Best Regards, Sergey Schetinin http://s3bk.com/ -- S3 Backup http://word-to-html.com/ -- Word to HTML Converter _______________________________________________ PEAK mailing list [email protected] http://www.eby-sarna.com/mailman/listinfo/peak
py26.patch
(application/octet-stream, 2.6 KB)
Index: stm.py
===================================================================
--- stm.py (revision 2595)
+++ stm.py (working copy)
@@ -1,6 +1,6 @@
"""Software Transactional Memory and Observers"""
-import weakref, sys, heapq, UserList, UserDict, sets
+import weakref, sys, heapq, UserList, UserDict
from peak.util.extremes import Max
from peak.util import decorators
try:
Index: trellis.py
===================================================================
--- trellis.py (revision 2595)
+++ trellis.py (working copy)
@@ -1,7 +1,7 @@
from thread import get_ident
from weakref import ref
from peak.util import addons, decorators
-import sys, UserDict, UserList, sets, stm, types, new, weakref, copy
+import sys, UserDict, UserList, stm, types, new, weakref, copy
from peak.util.extremes import Max
from peak.util.symbols import Symbol, NOT_GIVEN
@@ -42,12 +42,13 @@
try:
set = set
except NameError:
+ import sets
set = sets.Set
frozenset = sets.ImmutableSet
set_like = sets.BaseSet
dictlike = dict, sets.BaseSet
else:
- set_like = set, frozenset, sets.BaseSet
+ set_like = set, frozenset
dictlike = (dict,) + set_like
@@ -506,7 +508,7 @@
return ReadOnlyCell(rule, None, discrete)
elif rule is None:
return Value(v, discrete)
- return ReadOnlyCell.__new__(cls, rule, value, discrete)
+ return ReadOnlyCell.__new__(cls)#, rule, value, discrete)
def _check_const(self):
pass # we can never become Constant
@@ -529,8 +531,9 @@
super(Cell, self).set_value(value)
if self._needs_init:
schedule(self)
+ else:
+ cancel(self)
-
value = property(get_value, set_value)
def dirty(self):
@@ -748,6 +751,8 @@
except KeyError:
name = self.__name__
cell = cells.setdefault(name, self.make_cell(typ, ob, name))
+ if ctrl.active:
+ on_undo(cells.pop, name)
return cell.value
def __repr__(self):
@@ -1240,6 +1245,9 @@
strategy is used in each recalcultion that changes the list. If what you
really want is e.g. a sorted read-only view on a set, don't use this.
"""
+ if hasattr(UserList.UserList, '__metaclass__'):
+ class __metaclass__(Component.__metaclass__, UserList.UserList.__metaclass__):
+ pass
updated = todo(lambda self: self.data[:])
future = updated.future
@@ -1351,7 +1359,7 @@
-class Set(sets.Set, Component):
+class Set(set, Component):
"""Mutable set that recalculates observers when it's changed
The ``added`` and ``removed`` attributes can be watched for changes, but