On Nov 22, 11:15 am, Michael Bayer <mike...@zzzcomputing.com> wrote:
> I'm assuming the reason for "proxy objects" is so that usage would continue > to look like: > blogpost.body = "new body" Right, exactly. > So for that kind of thing, if you want certain operations to proceed under > the "umbrella" of some context, like who the current user is, Python context > managers are very neat for this. > > with security_manager.user(some_user): > blogpost.body = "new body" Using a context manager is a nice idea. Although thread-locals... a bit icky. > You'd normally use @property on your BlogPost object to intercept read/set > events, or the @validates decorator which catches only set events, to achieve > this. BlogPost could find the local context manager usually via thread > local. If I use properties with the same names as the columns, how can I avoid them clobbering the actual columns? I did try subclassing DeclarativeMeta to enforce column_prefix='_', but it I think I misunderstood what that does, because it made query(BlogPost).get(...) complain about the DB not having an _id field. Does column_prefix change what SA expects the DB columns look like, or just the names of the attributes? -- 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.