On 30 нояб, 21:07, Michael Bayer <[EMAIL PROTECTED]> wrote:
> hey there -
>
> this is line 179 right now:
>
>              if bind in conn_dict:
>
> similar mismatches in the stacktrace are present for lines 505 and 509
> (line 505 is a blank line now).
>
> the full snip of code is:
>
>              if bind in conn_dict:
>                  (conn, trans, autoclose) = conn_dict[bind]
>                  self.__connections[conn] =
> self.__connections[bind.engine] = (conn, conn.begin_nested(), autoclose)
>                  return conn
>
> so my guess is that you arent running the most recent trunk.

Of course you're right. I'd run script on another host by chance,
sorry.

There's the output with revision 3846:

Exception in thread Thread-5:
Traceback (most recent call last):
  File "threading.py", line 442, in __bootstrap
    self.run()
  File "./camper.py", line 122, in run
    walk(session, theone, root)
  File "./camper.py", line 91, in walk
    session.commit()
  File "/usr/lib/python2.4/site-packages/sqlalchemy/orm/scoping.py",
line 74, in do
    return getattr(self.registry(), name)(*args, **kwargs)
  File "/usr/lib/python2.4/site-packages/sqlalchemy/orm/session.py",
line 484, in commit
    self.transaction = self.transaction.commit()
  File "/usr/lib/python2.4/site-packages/sqlalchemy/orm/session.py",
line 211, in commit
    self.session.flush()
  File "/usr/lib/python2.4/site-packages/sqlalchemy/orm/session.py",
line 686, in flush
    self.uow.flush(self, objects)
  File "/usr/lib/python2.4/site-packages/sqlalchemy/orm/
unitofwork.py", line 207, in flush
    flush_context.execute()
  File "/usr/lib/python2.4/site-packages/sqlalchemy/orm/
unitofwork.py", line 434, in execute
    UOWExecutor().execute(self, head)
  File "/usr/lib/python2.4/site-packages/sqlalchemy/orm/
unitofwork.py", line 1053, in execute
    self.execute_save_steps(trans, task)
  File "/usr/lib/python2.4/site-packages/sqlalchemy/orm/
unitofwork.py", line 1067, in execute_save_steps
    self.save_objects(trans, task)
  File "/usr/lib/python2.4/site-packages/sqlalchemy/orm/
unitofwork.py", line 1058, in save_objects
    task.mapper.save_obj(task.polymorphic_tosave_objects, trans)
  File "/usr/lib/python2.4/site-packages/sqlalchemy/orm/mapper.py",
line 1104, in save_obj
    raise exceptions.ConcurrentModificationError("Updated rowcount %d
does not match number of objects updated %d" % (rows, len(update)))
ConcurrentModificationError: Updated rowcount 0 does not match number
of objects updated 1


The code:

from sqlalchemy import create_engine, MetaData, Table, Column, types,
schema
from sqlalchemy.orm import mapper, relation, backref, create_session,
scoped_session, sessionmaker
from sqlalchemy.exceptions import IntegrityError
metadata = MetaData()
u_table = Table('auth_user', metadata, \
    Column('id', types.Integer, primary_key=True), \
    Column('username', types.String(30)))
f_table = Table('fs_file', metadata, \
    Column('id', types.Integer, primary_key=True), \
    Column('user_id', None, schema.ForeignKey("auth_user.id")), \
    Column('path', types.String, unique=True), \
    Column('ls', types.PickleType, nullable=False))

class User(object):
    pass

mapper(User, u_table)
mapper(Path, f_table)


session = scoped_session(sessionmaker(transactional=True,
autoflush=False))
db = create_engine("postgres://...")
session.configure(bind=db)

def walk(session, theone, root):
    f_table.delete(f_table.c.user_id==theone.id).execute()
    f_table.insert().execute(user_id=theone.id, path='/', ls=ls)
    session.flush()
    session.connection()
    transaction = session.begin()
...
nested = session.begin_nested()
        try:
            f_table.insert().execute(user_id=theone.id, path=relpath, ls =
ls)
        except IntegrityError:
            stuff = session.query(Path).select_from(..).. #update
        session.commit() # line 91
    session.commit()
    session.clear()

class arrange(Thread):
    def __init__ (self, event):
        Thread.__init__(self)
        self.e = event
    def run(self):
        if not metadata.is_bound():
            metadata.bind = db
        session.connection()
        theone = session.query(User).filter_by(username=user).first()
        if not theone:
            session.clear()
            session.close()
            return
        walk(session, theone, root)
        ...
        #possible delete/update/insert statements
...

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to