[sqlalchemy] convert_unicode and Query strings with a helping of PyODBC and FreeTDS on OS X

2009-07-08 Thread John Hampton

So, the problem that I am having is that when I try to do a query, I get
back the following error:

sqlalchemy.exc.ProgrammingError: (ProgrammingError) ('The SQL contains 0
parameter markers, but 1 parameters were supplied', 'HY000')

Yet, in the query output, it is clear that there is a value supplied.

Digging into this I found I could reproduce it at the pyodbc layer.
Messing around some more, I found that if I explicitly encoded the
strings, both the query and the bind param, to utf-8, that it would
succeed.  So:

cur.execute(u'select * from pk010033 where manufactureorder_i = ?',
(u'MO-MK25',))

fails, but

cur.execute(u'select * from pk010033 where manufactureorder_i =
?'.encode('utf-8'), (u'MO-MK25'.encode('utf-8'),))

worked.

I am now using a sqlalchemy.types.Unicode type for the bind param, and
am still getting the error.

So, I'm thinking that perhaps the query string emitted from the query
module isn't being explicitly encoded.  I don't really know where to
start looking in order to verify this, however.

Any help or pointers are greatly appreciated

-John

P.S.  I am using convert_unicode=True in the database connection string.

--~--~-~--~~~---~--~~
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 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: convert_unicode and Query strings with a helping of PyODBC and FreeTDS on OS X

2009-07-08 Thread John Hampton

John Hampton wrote:
 So, the problem that I am having is that when I try to do a query, I get
 back the following error:
 
 sqlalchemy.exc.ProgrammingError: (ProgrammingError) ('The SQL contains 0
 parameter markers, but 1 parameters were supplied', 'HY000')

Due to ticket #1313 I tried out the 0.6 branch.  It successfully fixed
this issue.  So, not quite sure what it was, but it's fixed ;)


-John

--~--~-~--~~~---~--~~
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 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: unit testing idioms

2009-07-08 Thread Chris Withers

Mike Orr wrote:
 You generally want to use a test database rather than depending on a
 rollback to preserve the live data, because who knows when something
 might go wrong (e.g.,, a stray commit you didn't notice).  

True. Although I wonder how fixture (http://code.google.com/p/fixture/) 
reverts the changes it makes at the end of each test? (cc'ing in Kumar 
in case he can provide a short summary :-) )

 You can create and populate the database in the setUp function Nose
 runs, and drop the tables in the tearDown function.  These functions
 can be run for every test or only on on entering/exiting the module,
 depending on how you name them them.

Yep, I do like this about Nose. I guess zope.testing's Layers concept 
would work well with this too...

 want to do part of that thing.  Beware that if you have configured
 websetup.py this way, it will be run for every test unless you disable
 that.

Yeah, I moved the calls to a package-level setUp function in my 
functional tests sub-package.

 If your data is mainly added to rather than modified in place, you may
 want to test against real data collected a month or two ago.  In that
 case you may want the real database or a copy of it, but the database
 may be too large to create/import multiple times during a test.  In
 that case it gets a bit more difficult, plus you actually have to
 import the data from somewhere rather than inserting fixed dummy data.
  Perhaps in this case you'll want to load it from a SQL dump file made
 earlier, or a tab-delimited file.

Are there any tool sets that support this kind of thing?
So far I've only found Kumar's fixture package, are there any others 
like it?

 If you put only your read-only tests in the Pylons app and keep your
 read-write tests elsewhere, then it would be safer to run the
 read-only tests against the live database.

I don't think I'd ever be insane enough to run tests against a live 
database ;-)

Chris

-- 
Simplistix - Content Management, Zope  Python Consulting
- http://www.simplistix.co.uk

--~--~-~--~~~---~--~~
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 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: convert_unicode and Query strings with a helping of PyODBC and FreeTDS on OS X

2009-07-08 Thread Michael Bayer

John Hampton wrote:

 John Hampton wrote:
 So, the problem that I am having is that when I try to do a query, I get
 back the following error:

 sqlalchemy.exc.ProgrammingError: (ProgrammingError) ('The SQL contains 0
 parameter markers, but 1 parameters were supplied', 'HY000')

 Due to ticket #1313 I tried out the 0.6 branch.  It successfully fixed
 this issue.  So, not quite sure what it was, but it's fixed ;)

FreeTDS/pyodbc on OSX wants SQL sent as encoded strings, not unicode
objects.   Ideally this would be reported as a bug in pyodbc and/or
freetds (likely pyodbc, where I've had unicode issues before).


--~--~-~--~~~---~--~~
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 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] NameError: name 'City' is not defined

2009-07-08 Thread AkA

Hi,
I've tried and searched the forum but there's something happening with
my TG2 model and sqlalchemy that's in my way:
I've written a file named address.py with two classes, Address and
City and imported both in my __init__.py.
Now I want to have them related as one to many and wrote:

__all__ = ['Address', 'City']

class City(DeclarativeBase):

__tablename__ = 'tg_city'

#{ Columns
#{ Relations
addresses = relation('Address', order_by=Address.id,
backref='city')

and

class Address(DeclarativeBase):

__tablename__ = 'tg_address'

#{ Columns
#{ Relations
city_id  = Column(Integer, ForeignKey('city.id'))
city  = relation('City', backref=backref('addresses',
order_by=id))

But starting my app gives me the error
addresses = relation('Address', order_by=Address.id, backref='city')
NameError: name 'Address' is not defined
so I checked my auth.py file as an example but cannot see anything
missing in my adres.py file.
Does somebody have any suggestions what can be wrong?

--~--~-~--~~~---~--~~
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 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] controlling the contents of a collection in an ORM object

2009-07-08 Thread jess

I want to maintain some groups that change over time.  Specifically, I
have a group table with group names and other attributes.  Every time
an item enters a group, a record is created in an item table with an
entry timestamp (and some other attributes).  Whenever an item leaves
a group, its item table record is updated with an exit timestamp.  I
need to access the group as it was at any specific time.  I cannot
find a nice way with SQLAlchemy ORM to maintain such a Group object
with its Item collection.

The problem seems to be controlling the contents of a collection in an
ORM object.  Using joins I can limit the returned objects to ones that
have certain traits in the associated collection but the collection
itself always has all the collectable objects.

In the orm tutorial, the section Selecting Entities from Subqueries
comes close.  That query returns the user (with all its associated
addresses) and a list of the desired addresses.  Is there any way to
get the User object jack with only the filtered addresses it the
addresses collection of the object?

One way to do this is to set up the relation to filter the objects
(addresses) that appear in the collection (user.addresses).  I do not
want to do this because I want build the query after the mapping is
done (e.g. give me all users that use gmail or something else for
email).

Is this the same question as asked in filter relation based on column
values where the recommnendation was to subclass Query?  Similar
threads are Extended Query subclass with add_named_column method
and  Optimizing joined entity loads.

Dynamic Relation Loaders in the SQLAlchemy documentation has an
approach where the collection is returned as a Query object which can
be filtered.  It seems that one can initialize, append to, and remove
from the collection (query) but the interface requires the filter to
be specified and SQL is generated whenever the collection is accessed.

What is the best way to solve this problem?

--~--~-~--~~~---~--~~
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 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: controlling the contents of a collection in an ORM object

2009-07-08 Thread Michael Bayer

jess wrote:

 I want to maintain some groups that change over time.  Specifically, I
 have a group table with group names and other attributes.  Every time
 an item enters a group, a record is created in an item table with an
 entry timestamp (and some other attributes).  Whenever an item leaves
 a group, its item table record is updated with an exit timestamp.  I
 need to access the group as it was at any specific time.  I cannot
 find a nice way with SQLAlchemy ORM to maintain such a Group object
 with its Item collection.

 The problem seems to be controlling the contents of a collection in an
 ORM object.  Using joins I can limit the returned objects to ones that
 have certain traits in the associated collection but the collection
 itself always has all the collectable objects.

this is available via contains_eager().  See the examples at
http://www.sqlalchemy.org/docs/05/mappers.html#routing-explicit-joins-statements-into-eagerly-loaded-collections
.



--~--~-~--~~~---~--~~
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 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: 0.4 to 0.5 upgrade and 'One-to-many relation fails with unsaved, pending instance and is an orphan' error

2009-07-08 Thread Brad Wells

Thank you for the detailed explanation of the problem and my possible
solutions.

On Jul 3, 10:14 am, Michael Bayer mike...@zzzcomputing.com wrote:
 oh man, i missed the biggest part of this one, after I noticed that  
 you weren't doing anything to put the PhoneNumber in the session.    
 Don't use Session.mapper.  That is the main problem you're having in  
 this specific case.   Auto-adding free-standing objects to the session  
 is a bad idea and I've downplayed the crap out of this legacy feature  
 for years now.

 On Jul 2, 2009, at 7:21 PM, Brad Wells wrote:



  In the process of upgrading from 0.4 to 0.5 I've come across a
  troubling issue. With the following setup:

  

  from sqlalchemy import Table, Column, Integer, String, MetaData,
  create_engine, ForeignKey
  from sqlalchemy.orm import relation, sessionmaker, scoped_session

  engine = create_engine('sqlite:///mystuff.sqlite', echo=True)

  Session = scoped_session(sessionmaker(autoflush=True,
  transactional=True, bind=engine))
  metadata = MetaData()
  mapper = Session.mapper

  time_zones = Table('time_zones', metadata,
                  Column('id', Integer, primary_key=True),
                  Column('name', String(35)))

  contacts = Table('contacts', metadata,
                  Column('id', Integer, primary_key=True),
                  Column('display_as', String(35)),
                  Column('time_zone_id', Integer, ForeignKey
  ('time_zones.id')))

  phone_numbers = Table('phone_numbers', metadata,
                  Column('id', Integer, primary_key=True),
                  Column('number', String(35)),
                  Column('contact_id', Integer, ForeignKey
  ('contacts.id')))

  class TimeZone(object): pass
  class Contact(object): pass
  class PhoneNumber(object): pass

  mapper(TimeZone, time_zones)
  mapper(Contact, contacts, properties={
     'time_zone': relation(TimeZone, backref='contacts'),
     'phone_numbers': relation(PhoneNumber, backref='contact',
  cascade='all, delete-orphan')
  })
  mapper(PhoneNumber, phone_numbers)

  metadata.create_all(bind=engine)

  ##

  Under 0.4 the following code executes fine:

  

  c = Contact(display_as='Fake, User')
  c.time_zone = TimeZone.query.filter_by(name='Africa/Algiers').first()
  ph = PhoneNumber(full='1234567890')
  c.phone_numbers.append(ph)
  Session.commit()

  

  But under 0.5 I receive an orphaned object error (see below for full
  output). I understand that the TimeZone query causes a flush in
  between the creation of the Contact and of the PhoneNumber. Without
  the flush in between (if the TimeZone query line is removed) SA 0.5 is
  correctly able execute the sample script.

  As per this thread (http://groups.google.com/group/sqlalchemy/
  browse_thread/thread/6c71c61bc59223f?tvc=2) I see that a suggested
  remedy is to change the relation to cascade='all' rather than
  cascade='all, delete-orphan'.
  I would prefer not to do this as it really does make no sense in this
  case to have a PhoneNumber without a Contact. I could also set the
  relation via 'ph.contact = contact' but I would prefer to not have to
  comb all of our existing code for this new class of bug.

  What doesn't make sense to me is why 0.4 was able to correctly delay
  the insert of the new phone number record until after the query for
  the collection and now 0.5 can't.

  Thank you for the assistance
  -Brad

  Below is the full echo output of 0.4 and 0.5

  0.4.8dev_r5095:
  2009-07-02 18:51:17,391 INFO sqlalchemy.engine.base.Engine.0x..70
  BEGIN
  2009-07-02 18:51:17,391 INFO sqlalchemy.engine.base.Engine.0x..70
  INSERT INTO contacts (display_as, time_zone_id) VALUES (?, ?)
  2009-07-02 18:51:17,391 INFO sqlalchemy.engine.base.Engine.0x..70
  ['Fake, User', None]
  2009-07-02 18:51:17,391 INFO sqlalchemy.engine.base.Engine.0x..70
  SELECT time_zones.id AS time_zones_id, time_zones.name AS
  time_zones_name FROM time_zones WHERE time_zones.name = ? ORDER BY
  time_zones.oid LIMIT 1 OFFSET 0
  2009-07-02 18:51:17,391 INFO sqlalchemy.engine.base.Engine.0x..70
  ['Africa/Algiers']
  2009-07-02 18:51:17,407 INFO sqlalchemy.engine.base.Engine.0x..70
  SELECT phone_numbers.id AS phone_numbers_id, phone_numbers.number AS
  phone_numbers_number, phone_numbers.contact_id AS
  phone_numbers_contact_id FROM phone_numbers WHERE
  phone_numbers.contact_id = ? ORDER BY phone_numbers.oid
  2009-07-02 18:51:17,407 INFO sqlalchemy.engine.base.Engine.0x..70 [4]
  2009-07-02 18:51:17,407 INFO sqlalchemy.engine.base.Engine.0x..70
  INSERT INTO phone_numbers (number, contact_id) VALUES (?, ?)
  2009-07-02 18:51:17,407 INFO sqlalchemy.engine.base.Engine.0x..70
  [None, 4]
  2009-07-02 18:51:17,407 INFO sqlalchemy.engine.base.Engine.0x..70
  COMMIT

  0.5.4p2:
  sa_test.py:8: SADeprecationWarning: The 'transactional' 

[sqlalchemy] AttributeError: '_ProxyImpl' object has no attribute 'get_history'

2009-07-08 Thread Brad Wells

I receive AttributeError: '_ProxyImpl' object has no attribute
'get_history' when attempting to use session.is_modified  on a class
with a synonym with a descriptor. Removing the descriptor from the
synonym prevents the error. Code and full traceback below.

#
from sqlalchemy import Table, Column, Integer, String, MetaData,
create_engine, ForeignKey
from sqlalchemy.orm import relation, sessionmaker, scoped_session,
mapper, synonym, object_session
from sqlalchemy.orm.interfaces import MapperExtension


class SynonymProp(object):
def __init__(self, attribute):
self._attribute = attribute

def __set__(s, obj, value):
setattr(obj, s._attribute, value)
def __delete__(s, obj):
delattr(obj, s._attribute)
def __get__(s, obj, owner):
if obj is None:
return s
return getattr(obj, s._attribute)

class Extension(MapperExtension):

def before_update(self, mapper, connection, instance):
object_session(instance).is_modified(instance,
include_collections=False)


engine = create_engine('sqlite:///', echo=False)

Session = scoped_session(sessionmaker(autoflush=True,
autocommit=False, bind=engine))
metadata = MetaData()

bananas = Table('bananas', metadata,
   Column('id', Integer, primary_key=True),
   Column('name', String(35)))

class Banana(object): pass

mapper(Banana, bananas, extension=Extension(), properties={
'name': synonym('_name', map_column=True, descriptor=SynonymProp
('_name'))
})

metadata.create_all(bind=engine)

b1 = Banana()
Session.add(b1)
Session.commit()

b1.name = 'Bob'

Session.commit()
#



Traceback (most recent call last):
  File sa_test.py, line 50, in module
Session.commit()
  File c:\program files\python\lib\site-packages\sqlalchemy-0.5.4p2-
py2.5.egg\sqlalchemy\orm\scoping.py, line 121, in do
return getattr(self.registry(), name)(*args, **kwargs)
  File C:\PROGRA~1\Python\lib\site-packages\sqlalchemy-0.5.4p2-
py2.5.egg\sqlalchemy\orm\session.py, line 673, in commit
self.transaction.commit()
  File C:\PROGRA~1\Python\lib\site-packages\sqlalchemy-0.5.4p2-
py2.5.egg\sqlalchemy\orm\session.py, line 378, in commit
self._prepare_impl()
  File C:\PROGRA~1\Python\lib\site-packages\sqlalchemy-0.5.4p2-
py2.5.egg\sqlalchemy\orm\session.py, line 362, in _prepare_impl
self.session.flush()
  File C:\PROGRA~1\Python\lib\site-packages\sqlalchemy-0.5.4p2-
py2.5.egg\sqlalchemy\orm\session.py, line 1354, in flush
self._flush(objects)
  File C:\PROGRA~1\Python\lib\site-packages\sqlalchemy-0.5.4p2-
py2.5.egg\sqlalchemy\orm\session.py, line 1432, in _flush
flush_context.execute()
  File c:\program files\python\lib\site-packages\sqlalchemy-0.5.4p2-
py2.5.egg\sqlalchemy\orm\unitofwork.py, line 257, in execute
UOWExecutor().execute(self, tasks)
  File c:\program files\python\lib\site-packages\sqlalchemy-0.5.4p2-
py2.5.egg\sqlalchemy\orm\unitofwork.py, line 720, in execute
self.execute_save_steps(trans, task)
  File c:\program files\python\lib\site-packages\sqlalchemy-0.5.4p2-
py2.5.egg\sqlalchemy\orm\unitofwork.py, line 735, in
execute_save_steps
self.save_objects(trans, task)
  File c:\program files\python\lib\site-packages\sqlalchemy-0.5.4p2-
py2.5.egg\sqlalchemy\orm\unitofwork.py, line 726, in save_objects
task.mapper._save_obj(task.polymorphic_tosave_objects, trans)
  File c:\program files\python\lib\site-packages\sqlalchemy-0.5.4p2-
py2.5.egg\sqlalchemy\orm\mapper.py, line 1251, in _save_obj
mapper.extension.before_update(mapper, connection, state.obj())
  File c:\program files\python\lib\site-packages\sqlalchemy-0.5.4p2-
py2.5.egg\sqlalchemy\orm\util.py, line 234, in _do
ret = getattr(ext, method)(*args, **kwargs)
  File sa_test.py, line 22, in before_update
object_session(instance).is_modified(instance,
include_collections=False)
  File C:\PROGRA~1\Python\lib\site-packages\sqlalchemy-0.5.4p2-
py2.5.egg\sqlalchemy\orm\session.py, line 1483, in is_modified
(added, unchanged, deleted) = attr.get_history(instance,
passive=passive)
  File C:\PROGRA~1\Python\lib\site-packages\sqlalchemy-0.5.4p2-
py2.5.egg\sqlalchemy\orm\attributes.py, line 108, in get_history
return self.impl.get_history(instance_state(instance),
instance_dict(instance), **kwargs)
AttributeError: '_ProxyImpl' object has no attribute 'get_history'
--~--~-~--~~~---~--~~
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 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] column sorting

2009-07-08 Thread mg

I am using the declarative extension and have a class like this:
class EmmaMember(Base):
__tablename__ = 'members'
id = Column('id', Integer(),
Sequence('member_seq'), primary_key=True,
nullable=False)
account_id = Column('account_id', Integer() )
email = Column('email', String() )
member_since = Column(',ember_since', DateTime(timezone=False),
default=func.now() )

One of the things I would like to do is to order a query by the email
domain, or by the email mailbox. Is there any easy way to do this with
the session and orm?

Here is an example sql query that does what I am looking for:

select id, email, SPLIT_PART(LOWER(email), '@', 1) AS mailbox,
SPLIT_PART(LOWER(email), '@', 2) AS domain
from members order by mailbox desc;

thanks,
Matt
--~--~-~--~~~---~--~~
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 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] ironpython

2009-07-08 Thread quirogaco

sqlalchemy run in ironpython?

connect to database?

examples?

thank's

JCR


--~--~-~--~~~---~--~~
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 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: controlling the contents of a collection in an ORM object

2009-07-08 Thread jess

Thank you very much.  contains_eager does the trick.


--~--~-~--~~~---~--~~
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 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: AttributeError: '_ProxyImpl' object has no attribute 'get_history'

2009-07-08 Thread Michael Bayer

indeed.  fixed this in r6099.

On Jul 8, 2009, at 6:09 PM, Brad Wells wrote:


 I receive AttributeError: '_ProxyImpl' object has no attribute
 'get_history' when attempting to use session.is_modified  on a class
 with a synonym with a descriptor. Removing the descriptor from the
 synonym prevents the error. Code and full traceback below.

 #
 from sqlalchemy import Table, Column, Integer, String, MetaData,
 create_engine, ForeignKey
 from sqlalchemy.orm import relation, sessionmaker, scoped_session,
 mapper, synonym, object_session
 from sqlalchemy.orm.interfaces import MapperExtension


 class SynonymProp(object):
def __init__(self, attribute):
self._attribute = attribute

def __set__(s, obj, value):
setattr(obj, s._attribute, value)
def __delete__(s, obj):
delattr(obj, s._attribute)
def __get__(s, obj, owner):
if obj is None:
return s
return getattr(obj, s._attribute)

 class Extension(MapperExtension):

def before_update(self, mapper, connection, instance):
object_session(instance).is_modified(instance,
 include_collections=False)


 engine = create_engine('sqlite:///', echo=False)

 Session = scoped_session(sessionmaker(autoflush=True,
 autocommit=False, bind=engine))
 metadata = MetaData()

 bananas = Table('bananas', metadata,
   Column('id', Integer, primary_key=True),
   Column('name', String(35)))

 class Banana(object): pass

 mapper(Banana, bananas, extension=Extension(), properties={
'name': synonym('_name', map_column=True, descriptor=SynonymProp
 ('_name'))
 })

 metadata.create_all(bind=engine)

 b1 = Banana()
 Session.add(b1)
 Session.commit()

 b1.name = 'Bob'

 Session.commit()
 #



 Traceback (most recent call last):
  File sa_test.py, line 50, in module
Session.commit()
  File c:\program files\python\lib\site-packages\sqlalchemy-0.5.4p2-
 py2.5.egg\sqlalchemy\orm\scoping.py, line 121, in do
return getattr(self.registry(), name)(*args, **kwargs)
  File C:\PROGRA~1\Python\lib\site-packages\sqlalchemy-0.5.4p2-
 py2.5.egg\sqlalchemy\orm\session.py, line 673, in commit
self.transaction.commit()
  File C:\PROGRA~1\Python\lib\site-packages\sqlalchemy-0.5.4p2-
 py2.5.egg\sqlalchemy\orm\session.py, line 378, in commit
self._prepare_impl()
  File C:\PROGRA~1\Python\lib\site-packages\sqlalchemy-0.5.4p2-
 py2.5.egg\sqlalchemy\orm\session.py, line 362, in _prepare_impl
self.session.flush()
  File C:\PROGRA~1\Python\lib\site-packages\sqlalchemy-0.5.4p2-
 py2.5.egg\sqlalchemy\orm\session.py, line 1354, in flush
self._flush(objects)
  File C:\PROGRA~1\Python\lib\site-packages\sqlalchemy-0.5.4p2-
 py2.5.egg\sqlalchemy\orm\session.py, line 1432, in _flush
flush_context.execute()
  File c:\program files\python\lib\site-packages\sqlalchemy-0.5.4p2-
 py2.5.egg\sqlalchemy\orm\unitofwork.py, line 257, in execute
UOWExecutor().execute(self, tasks)
  File c:\program files\python\lib\site-packages\sqlalchemy-0.5.4p2-
 py2.5.egg\sqlalchemy\orm\unitofwork.py, line 720, in execute
self.execute_save_steps(trans, task)
  File c:\program files\python\lib\site-packages\sqlalchemy-0.5.4p2-
 py2.5.egg\sqlalchemy\orm\unitofwork.py, line 735, in
 execute_save_steps
self.save_objects(trans, task)
  File c:\program files\python\lib\site-packages\sqlalchemy-0.5.4p2-
 py2.5.egg\sqlalchemy\orm\unitofwork.py, line 726, in save_objects
task.mapper._save_obj(task.polymorphic_tosave_objects, trans)
  File c:\program files\python\lib\site-packages\sqlalchemy-0.5.4p2-
 py2.5.egg\sqlalchemy\orm\mapper.py, line 1251, in _save_obj
mapper.extension.before_update(mapper, connection, state.obj())
  File c:\program files\python\lib\site-packages\sqlalchemy-0.5.4p2-
 py2.5.egg\sqlalchemy\orm\util.py, line 234, in _do
ret = getattr(ext, method)(*args, **kwargs)
  File sa_test.py, line 22, in before_update
object_session(instance).is_modified(instance,
 include_collections=False)
  File C:\PROGRA~1\Python\lib\site-packages\sqlalchemy-0.5.4p2-
 py2.5.egg\sqlalchemy\orm\session.py, line 1483, in is_modified
(added, unchanged, deleted) = attr.get_history(instance,
 passive=passive)
  File C:\PROGRA~1\Python\lib\site-packages\sqlalchemy-0.5.4p2-
 py2.5.egg\sqlalchemy\orm\attributes.py, line 108, in get_history
return self.impl.get_history(instance_state(instance),
 instance_dict(instance), **kwargs)
 AttributeError: '_ProxyImpl' object has no attribute 'get_history'
 


--~--~-~--~~~---~--~~
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 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en