Re: [sqlalchemy] 0.6beta3 issue with topological.py

2010-04-18 Thread Michael Bayer
There was a small adjustment made to topological in beta3, which was erroneous 
and later reversed, that is a likely source of this.Beyond that, 
unitofwork.py and topological.py had hardly changed for years.

But the big news is that all of topological.py and unitofwork.py have been 
rewritten from scratch in the current tip and will be in 0.6.0.   So that is 
where you should be right now.



On Apr 17, 2010, at 10:31 PM, percious wrote:

 Some things have changed in 0.6beta3 from beta2 and they are breaking
 my database loading script.  I don't yet have an example that causes
 this, but I am seeing an intermittent failure (sometimes when I run my
 program it's fine, without changing anything I'll run it again and it
 fails.)  I can show you the error, and describe that my model has a
 heckovalota inheritance.  Maybe you can decipher this message:
 
 Traceback (most recent call last):
  File /Users/percious/clients/mvpss/mvp2.1/src/mvp2.1/bootalchemy/
 bootalchemy/loader.py, line 310, in from_list
session.flush()
  File /Users/percious/clients/mvpss/mvp2.1/lib/python2.6/site-
 packages/SQLAlchemy-0.6beta3-py2.6.egg/sqlalchemy/orm/session.py,
 line 1332, in flush
self._flush(objects)
  File /Users/percious/clients/mvpss/mvp2.1/lib/python2.6/site-
 packages/SQLAlchemy-0.6beta3-py2.6.egg/sqlalchemy/orm/session.py,
 line 1410, in _flush
flush_context.execute()
  File /Users/percious/clients/mvpss/mvp2.1/lib/python2.6/site-
 packages/SQLAlchemy-0.6beta3-py2.6.egg/sqlalchemy/orm/unitofwork.py,
 line 252, in execute
tasks = self._sort_dependencies()
  File /Users/percious/clients/mvpss/mvp2.1/lib/python2.6/site-
 packages/SQLAlchemy-0.6beta3-py2.6.egg/sqlalchemy/orm/unitofwork.py,
 line 285, in _sort_dependencies
[t.mapper for t in self.tasks.itervalues() if t.base_task is t]
  File /Users/percious/clients/mvpss/mvp2.1/lib/python2.6/site-
 packages/SQLAlchemy-0.6beta3-py2.6.egg/sqlalchemy/topological.py,
 line 43, in sort_with_cycles
return [(n.item, [n.item for n in n.cycles or []]) for n in
 _sort(tuples, allitems, allow_cycles=True)]
  File /Users/percious/clients/mvpss/mvp2.1/lib/python2.6/site-
 packages/SQLAlchemy-0.6beta3-py2.6.egg/sqlalchemy/topological.py,
 line 193, in _sort
lead = cycle[0][0]
 IndexError: list index out of range
 
 /Users/percious/clients/mvpss/mvp2.1/lib/python2.6/site-packages/SQLAlchemy-0.6beta3-py2.6.egg/sqlalchemy/topological.py(193)_sort()
 - lead = cycle[0][0]
 (Pdb) cycle
 []
 (Pdb) u
 /Users/percious/clients/mvpss/mvp2.1/lib/python2.6/site-packages/SQLAlchemy-0.6beta3-py2.6.egg/sqlalchemy/topological.py(43)sort_with_cycles()
 - return [(n.item, [n.item for n in n.cycles or []]) for n in
 _sort(tuples, allitems, allow_cycles=True)]
 (Pdb) a
 tuples = set([(Mapper at 0x23a8eb0; ContestEventTypeGroup, Mapper
 at 0x23b21f0; ContestEventType), (Mapper at 0x207a2d0; Resource,
 sqlalchemy.orm.dependency.MapperStub object at 0x2497950), (Mapper
 at 0x207a2d0; Resource, Mapper at 0x207a2d0; Resource), (Mapper at
 0x207a2d0; Resource, sqlalchemy.orm.dependency.MapperStub object at
 0x266d6f0), (Mapper at 0x238e9b0; ContestResource,
 sqlalchemy.orm.dependency.MapperStub object at 0x2664ef0), (Mapper
 at 0x207a2d0; Resource, Mapper at 0x238e9b0; ContestResource),
 (Mapper at 0x238e890; ContestType, Mapper at 0x23f30b0;
 Tournament), (Mapper at 0x207a2d0; Resource, Mapper at 0x23f30b0;
 Tournament), (Mapper at 0x23f30b0; Tournament,
 sqlalchemy.orm.dependency.MapperStub object at 0x2497ff0), (Mapper
 at 0x207a2d0; Resource, sqlalchemy.orm.dependency.MapperStub object
 at 0x268b2f0), (Mapper at 0x207a2d0; Resource,
 sqlalchemy.orm.dependency.MapperStub object at 0x26d3c90), (Mapper
 at 0x207a2d0; Resource, Mapper at 0x23df210; Stat), (Mapper at
 0x238e890; ContestType, Mapper at 0x207a2d0; Resource), (Mapper at
 0x23f30b0; Tournament, Mapper at 0x207a2d0; Resource), (Mapper at
 0x238e890; ContestType, sqlalchemy.orm.dependency.MapperStub object
 at 0x2497950), (Mapper at 0x23b21f0; ContestEventType,
 sqlalchemy.orm.dependency.MapperStub object at 0x268ba90), (Mapper
 at 0x207a2d0; Resource, sqlalchemy.orm.dependency.MapperStub object
 at 0x2664ef0), (Mapper at 0x238e9b0; ContestResource,
 sqlalchemy.orm.dependency.MapperStub object at 0x266d6f0), (Mapper
 at 0x218cc50; StaffPosition, sqlalchemy.orm.dependency.MapperStub
 object at 0x26d3c90), (Mapper at 0x207a2d0; Resource,
 sqlalchemy.orm.dependency.MapperStub object at 0x24bccf0), (Mapper
 at 0x238e890; ContestType, sqlalchemy.orm.dependency.MapperStub
 object at 0x268ba90), (Mapper at 0x238e890; ContestType, Mapper at
 0x23a8eb0; ContestEventTypeGroup), (Mapper at 0x207a2d0; Resource,
 sqlalchemy.orm.dependency.MapperStub object at 0x2497ff0), (Mapper
 at 0x207a2d0; Resource, Mapper at 0x23b2770; ContestEvent)])
 allitems = [sqlalchemy.orm.dependency.MapperStub object at
 0x2497950, Mapper at 0x23f30b0; Tournament, Mapper at 0x238e890;
 ContestType, sqlalchemy.orm.dependency.MapperStub object at
 

[sqlalchemy] Any libraries or examples of how to let users define custom fields on SA tables/objects

2010-04-18 Thread Randy Syring
I am creating a web application that has the concept of organizations
and people.  I would like the end users to be able to define custom
fields on those objects as needed.  So,

User A (only default fields):

Organization:
- Name
- Zip

People:
- Name
- Phone Number

User B (has a few custom fields):

Organization:
- Name
- Zip
- Main Contact
- Phone

People:
- Name
- Phone Number
- Email Address

Obviously, customer B's customizations shouldn't affect User A's
usage.

So, this seems like a relatively common paradigm and I was hoping
someone might already know of a library or example application for
using SA to accomplish this.  I am looking for something akin to
Rail's acts_as_cutomizable plugin (http://github.com/trappist/
acts_as_customizable) for SA.

Thanks.

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



[sqlalchemy] SQLAlchemy 0.6.0 released

2010-04-18 Thread Michael Bayer
The first official 0.6 release of SQLAlchemy is now available.

0.6 includes a newly rewritten unit of work implementation originally slated 
for 0.7, but then as it went so well we decided on 0.6.1, and then because it 
continued to perform terrifically within several punishing environments we 
decided to go with 0.6.0.   I'm very excited to have 0.6.0 out with the clean 
UOW system, as the old one was pretty much the last vestige of an earlier era 
for SQLAlchemy.   As we come up on our 5th birthday, SQLAlchemy has grown and 
matured to a dramatic degree, thanks in large part to the very generous and 
supportive community who have pushed us to produce an ever more awesome product.

I hope everyone enjoys this release and don't hesitate to report any bugs on 
the wiki.  Thanks for sticking around.

Changes for 0.6 below are relative to 0.6beta3.   For a full overview of what 
0.6 is about, see the What's New? document at 
http://www.sqlalchemy.org/trac/wiki/06Migration .

Download SQLAlchemy 0.6.0 at:

http://www.sqlalchemy.org/download.html

0.6.0
=

- orm
  - Unit of work internals have been rewritten.  Units of work
with large numbers of objects interdependent objects 
can now be flushed without recursion overflows 
as there is no longer reliance upon recursive calls
[ticket:1081].  The number of internal structures now stays 
constant for a particular session state, regardless of 
how many relationships are present on mappings.  The flow 
of events now corresponds to a linear list of steps, 
generated by the mappers and relationships based on actual
work to be done, filtered through a single topological sort 
for correct ordering.  Flush actions are assembled using 
far fewer steps and less memory. [ticket:1742]

  - Along with the UOW rewrite, this also removes an issue
introduced in 0.6beta3 regarding topological cycle detection 
for units of work with long dependency cycles.  We now use
an algorithm written by Guido (thanks Guido!).

  - one-to-many relationships now maintain a list of positive
parent-child associations within the flush, preventing
previous parents marked as deleted from cascading a 
delete or NULL foreign key set on those child objects,
despite the end-user not removing the child from the old
association. [ticket:1764]

  - A collection lazy load will switch off default 
eagerloading on the reverse many-to-one side, since 
that loading is by definition unnecessary.  [ticket:1495]

  - Session.refresh() now does an equivalent expire()
on the given instance first, so that the refresh-expire
cascade is propagated.   Previously, refresh() was
not affected in any way by the presence of refresh-expire
cascade.   This is a change in behavior versus that
of 0.6beta2, where the lockmode flag passed to refresh()
would cause a version check to occur.  Since the instance
is first expired, refresh() always upgrades the object
to the most recent version.

  - The 'refresh-expire' cascade, when reaching a pending object,
will expunge the object if the cascade also includes
delete-orphan, or will simply detach it otherwise.
[ticket:1754]

  - id(obj) is no longer used internally within topological.py,
as the sorting functions now require hashable objects
only.  [ticket:1756]

  - The ORM will set the docstring of all generated descriptors
to None by default.  This can be overridden using 'doc'
(or if using Sphinx, attribute docstrings work too).

  - Added kw argument 'doc' to all mapper property callables 
as well as Column().  Will assemble the string 'doc' as 
the '__doc__' attribute on the descriptor.  

  - Usage of version_id_col on a backend that supports 
cursor.rowcount for execute() but not executemany() now works
when a delete is issued (already worked for saves, since those
don't use executemany()). For a backend that doesn't support 
cursor.rowcount at all, a warning is emitted the same
as with saves.  [ticket:1761]

  - The ORM now short-term caches the compiled form of
insert() and update() constructs when flushing lists of 
objects of all the same class, thereby avoiding redundant
compilation per individual INSERT/UPDATE within an 
individual flush() call.

  - internal getattr(), setattr(), getcommitted() methods
on ColumnProperty, CompositeProperty, RelationshipProperty
have been underscored (i.e. are private), signature has 
changed.

- engines
  - The C extension now also works with DBAPIs which use custom
sequences as row (and not only tuples). [ticket:1757]

- sql
  - Restored some bind-labeling logic from 0.5 which ensures
that tables with column names that overlap another column
of the form tablename_columnname won't produce 
errors if column._label is used as a bind name during
an UPDATE.  Test coverage which wasn't present in 0.5
 

[sqlalchemy] Re: SQLAlchemy 0.6.0 released

2010-04-18 Thread Domingo Aguilera
Congratulations Michael, keep it up!

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