[sqlalchemy] Re: How to force a before_update() run without changes to instrumented attributes

2010-10-27 Thread Nikolaj
Can you give an example of a forwards-compatible way to modify an attribute to mark the instance dirty without creating actual net changes? SA seems quite good at detecting my tricks. On Oct 27, 6:41 pm, Michael Bayer mike...@zzzcomputing.com wrote: On Oct 27, 2010, at 11:43 AM, Nikolaj wrote

[sqlalchemy] Cannot deepcopy() model instance with attribute mapped collection on it

2010-10-04 Thread Nikolaj
Hey, I had trouble deepcopying model instances that use attribute mapped collection classes. I'm aware that copying an instance implies a certain use case with a better solution - I accidentally hit this error when I had an instance as an attribute on an object I was deepcopy()ing. The following

[sqlalchemy] Re: Uninitialized coltype in PGDialect.get_columns() for custom column basetype

2010-09-30 Thread Nikolaj
= Table('testtable', metadata, autoload=True) Thanks, N On Sep 29, 9:58 pm, Michael Bayer mike...@zzzcomputing.com wrote: On Sep 29, 2010, at 3:37 PM, Nikolaj wrote: Hi there, I use the earthdistance and cube modules for PostgreSQL (http:// www.postgresql.org/docs/8.4/interactive

[sqlalchemy] Uninitialized coltype in PGDialect.get_columns() for custom column basetype

2010-09-29 Thread Nikolaj
Hi there, I use the earthdistance and cube modules for PostgreSQL (http:// www.postgresql.org/docs/8.4/interactive/earthdistance.html). These define some custom types and functions for doing great circle calculations. I ran into a problem with table introspection in PGDialect.get_columns(). The

[sqlalchemy] Declarative classproperty member problem in 0.6.4, not 0.6.3

2010-09-15 Thread Nikolaj
The following test fails in 0.6.4 but not 0.6.3 with AttributeError: type object 'Person' has no attribute 'foo'. Is this a deliberate change? It seems a bit weird that every @classproperty on a declarative subclass is accessed/run on import. from sqlalchemy import create_engine, Column, String

[sqlalchemy] Re: Merge(load=False) woes

2010-08-25 Thread Nikolaj
and its sideeffects. Thanks! On Aug 25, 4:02 pm, Michael Bayer mike...@zzzcomputing.com wrote: On Aug 25, 2010, at 10:47 AM, Michael Bayer wrote: On Aug 25, 2010, at 9:37 AM, Nikolaj wrote: Hello, I'm struggling to use the Beaker caching example in my project. Accessing any attribute

[sqlalchemy] Specifying additional primaryjoin conditions for bidirectional adjacency list relationship

2010-08-12 Thread Nikolaj
Hi there, I'm exploring the bidirectional adjacency list pattern described in the documentation (the scalar relationship is intentional): Person.child = relationship( Person, uselist=False, backref=backref('parent', remote_side=Person.id) ) However, I'd like to add an additional

[sqlalchemy] Proper way to make a TypeDecorator around Enum?

2010-08-09 Thread Nikolaj
I'm on MySQL and trying to create a type that stores enums as VARCHAR(255). However, the following code still issues an ENUM() DDL. What am I doing wrong here? class StringEnum(types.TypeDecorator): impl = types.Enum def __init__(self, *args, **kwargs): super(StringEnum,

[sqlalchemy] Re: Proper way to make a TypeDecorator around Enum?

2010-08-09 Thread Nikolaj
, at 8:24 AM, Nikolaj wrote: I'm on MySQL and trying to create a type that stores enums as VARCHAR(255). However, the following code still issues an ENUM() DDL. What am I doing wrong here? class StringEnum(types.TypeDecorator):    impl = types.Enum    def __init__(self, *args, **kwargs

[sqlalchemy] Re: Proper way to make a TypeDecorator around Enum?

2010-08-09 Thread Nikolaj
On Aug 9, 3:38 pm, Michael Bayer mike...@zzzcomputing.com wrote: its pulling off the types.Enum callable from self.__class__ (which actually seems unnecessary here, self.impl should be fine), then calling that with the given arguments.  So it should be setting up the native_enum=False part

[sqlalchemy] Adding columns to SELECT clause without having to filter result entities

2010-08-09 Thread Nikolaj
I have an association object pattern between Person and Item through PersonItem. Item is subclassed using single-table inheritance into FooItem and BarItem, with a column named 'foo' on FooItem (although it's obviously on the same shared table as BarItem). I'd like to query PersonItem and

[sqlalchemy] Eagerloading a polymorphic relationship's attributes

2010-07-31 Thread Nikolaj
I have a one to one relationship between Company and Employee where Employee is subclassed using joined table inheritance into Manager and Engineer. I'm trying to query for a list of companies with the employee eagerloaded including the type-specific columns. I've been looking at the example at

[sqlalchemy] Problems with synonym property using a mixin class

2010-07-24 Thread Nikolaj
I'm having trouble inheriting a synonym property from a mixin class. It obviously works if the call to synonym() is on the child class and just the get/set methods are left on the mixin. Here is an example: from sqlalchemy import create_engine, Column, ForeignKey from sqlalchemy.ext.declarative

[sqlalchemy] Session identity map and merge()

2010-07-14 Thread Nikolaj
I'm using consecutive merge() calls to fetch the same persistent instance from the Session. The test case below works as I expected: the first get_item() issues a SELECT, the second issues an UPDATE, the third does neither. However, in my large project, using the pattern below (without the

[sqlalchemy] Mapper object has no attribute _props

2010-07-11 Thread Nikolaj
I was trying to add an AttributeExtension to a property from my MapperExtension but I get this error when trying to access the property: AttributeError: 'Mapper' object has no attribute '_props' Here's a test case: from sqlalchemy import create_engine, Column from sqlalchemy.ext.declarative

[sqlalchemy] Re: Mapper object has no attribute _props

2010-07-11 Thread Nikolaj
Ah, it's pretty clear why this happens in Mapper.__init__: self._configure_extensions() self._configure_class_instrumentation() self._configure_properties() Should MapperExtensions that want to extend properties mess with mapper._init_properties instead? On Jul 11, 2:49 pm, Nikolaj nik

[sqlalchemy] Composite column with a relationship

2010-07-07 Thread Nikolaj
Hi there, I'd like to create a column composite for amounts of money and their currency. However, the difficulty comes in keeping the currencies in a separate table and enabling my composite to find this relationship. Is there some way to set the Currency on my Money type implementation

[sqlalchemy] UsageRecipes/UniqueObject without using declarative?

2010-06-20 Thread Nikolaj
Hi there, I'm trying to use the UniqueObject recipe for my project which does not use declarative_base(). However, I'm having trouble getting this to work and run into this error: sqlalchemy.orm.exc.UnmappedInstanceError: Class '__main__.Widget' is mapped, but this instance lacks