[sqlalchemy] Re: bisect.insort

2007-09-07 Thread jason kirtland

Jean-Philippe Dutreve wrote:
 Thanks Jason for your clear explanation.
 Is there any mean to do your suggestion to call the pure Python
 version without coping/pasting it into my module?

Not that I know of- the Python functions get overwritten by the C 
implementations when the module is imported.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: bisect.insort

2007-09-07 Thread sdobrev

On Friday 07 September 2007 13:54:03 Jean-Philippe Dutreve wrote:
 I was using SA 0.3.9 to insert an item in an ordered list with
 bisect method insort (py 2.5):

 mapper(Entry, table_entries)
 mapper(Account, table_accounts, properties = dict(
 entries = relation(Entry, lazy=True,
 backref=backref('account', lazy=False),
 collection_class=ordering_list('position'),
 order_by=[table_entries.c.position])
 ))
 bisect.insort(account.entries, an_entry)

 This is not working anymore with SA 0.4 beta5 : the list owns the
 item but not the other way.
  assert account.entries[0] is an_entry  # TRUE
  assert an_entry.account is account  # FALSE, currently is None

 Remark: it's working if I copy/paste the bisect method in my
 module.

collections were reworked in 0.4, so see what methods the insort() 
uses from your list, and see if they are simulated/wrapped in 
orm.collections.py. maybe there some unhooked one.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: bisect.insort

2007-09-07 Thread jason kirtland

Jean-Philippe Dutreve wrote:
 I was using SA 0.3.9 to insert an item in an ordered list with bisect
 method insort (py 2.5):
 
 mapper(Entry, table_entries)
 mapper(Account, table_accounts, properties = dict(
 entries = relation(Entry, lazy=True,
 backref=backref('account', lazy=False),
 collection_class=ordering_list('position'),
 order_by=[table_entries.c.position])
 ))
 bisect.insort(account.entries, an_entry)
 
 This is not working anymore with SA 0.4 beta5 : the list owns the item
 but not the other way.
  assert account.entries[0] is an_entry  # TRUE
  assert an_entry.account is account  # FALSE, currently is None
 
 Remark: it's working if I copy/paste the bisect method in my module.

This is a Python bug: the C version of insort ignores overridden 
'insert' methods on classes that derive from list, bypassing 
SQLAlchemy's collection hooks.

In prior SQLAlchemy versions, collections weren't real lists and insort 
does handle that case properly.  I'd suggest using the pure Python 
versions of the bisect functions going forward.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: bisect.insort

2007-09-07 Thread Jean-Philippe Dutreve

Thanks Jason for your clear explanation.
Is there any mean to do your suggestion to call the pure Python
version without coping/pasting it into my module?

On 7 sep, 16:28, jason kirtland [EMAIL PROTECTED] wrote:
 Jean-Philippe Dutreve wrote:
  I was using SA 0.3.9 to insert an item in an ordered list with bisect
  method insort (py 2.5):

  mapper(Entry, table_entries)
  mapper(Account, table_accounts, properties = dict(
  entries = relation(Entry, lazy=True,
  backref=backref('account', lazy=False),
  collection_class=ordering_list('position'),
  order_by=[table_entries.c.position])
  ))
  bisect.insort(account.entries, an_entry)

  This is not working anymore with SA 0.4 beta5 : the list owns the item
  but not the other way.
   assert account.entries[0] is an_entry  # TRUE
   assert an_entry.account is account  # FALSE, currently is None

  Remark: it's working if I copy/paste the bisect method in my module.

 This is a Python bug: the C version of insort ignores overridden
 'insert' methods on classes that derive from list, bypassing
 SQLAlchemy's collection hooks.

 In prior SQLAlchemy versions, collections weren't real lists and insort
 does handle that case properly.  I'd suggest using the pure Python
 versions of the bisect functions going forward.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---