[sqlalchemy] Adding business logic to Session by inheritance?

2010-11-22 Thread Torsten Landschoff
Hi again! This questions can probably only be answered by one of the developers of SQLAlchemy. I need to store information that is valid for the whole session in a sane place, together with accessor methods. I ended up extending the orm.Session class and passing my class via class_=MySession to

[sqlalchemy] Implementing fine-grained access control

2010-11-22 Thread Dan Ellis
I'd like to find some way to implement access controls on mapped objects, with the following features: * Example: given a BlogPost object, only the owner, or a superuser, would be allowed to set fields such as title and body. * Example: reading the body field would check the privacy field as well

[sqlalchemy] many-to-many doc clarification suggestion

2010-11-22 Thread Catherine Devlin
When I went looking for docs to remind myself how to build a many-to-many relationship, the first doc I found at http://www.sqlalchemy.org/docs/orm/extensions/declarative.html keywords = Table( 'keywords', Base.metadata, Column('author_id', Integer, ForeignKey('authors.id')),

[sqlalchemy] Re: Problems when querying the database

2010-11-22 Thread Alvaro Reinoso
So what do you suggest to get the instance by title? I can query the database by title to get the id and then query again to get the instance by id. What do you think? On Nov 17, 1:10 pm, Michael Bayer mike...@zzzcomputing.com wrote: On Nov 16, 2010, at 3:56 PM, Alvaro Reinoso wrote: Hi

[sqlalchemy] Advantage ov SQLAlchemy over plain SQL

2010-11-22 Thread A. S.
Hi! at the company I work for I'd like to propose introducing Python to replace the hopelessly outdated SAS scripts. SQLAlchemy seems like a good option for SQL handling and I can imagine modules specifically tailored to our needs. However, the other guys are slightly conservative and might

Re: [sqlalchemy] many-to-many doc clarification suggestion

2010-11-22 Thread Michael Bayer
On Nov 22, 2010, at 9:57 AM, Catherine Devlin wrote: When I went looking for docs to remind myself how to build a many-to-many relationship, the first doc I found at http://www.sqlalchemy.org/docs/orm/extensions/declarative.html keywords = Table( 'keywords', Base.metadata,

Re: [sqlalchemy] Implementing fine-grained access control

2010-11-22 Thread Michael Bayer
On Nov 22, 2010, at 9:30 AM, Dan Ellis wrote: I'd like to find some way to implement access controls on mapped objects, with the following features: * Example: given a BlogPost object, only the owner, or a superuser, would be allowed to set fields such as title and body. * Example:

Re: [sqlalchemy] Adding business logic to Session by inheritance?

2010-11-22 Thread Michael Bayer
On Nov 22, 2010, at 4:33 AM, Torsten Landschoff wrote: Hi again! This questions can probably only be answered by one of the developers of SQLAlchemy. I need to store information that is valid for the whole session in a sane place, together with accessor methods. I ended up extending the

Re: [sqlalchemy] Advantage ov SQLAlchemy over plain SQL

2010-11-22 Thread Mark Erbaugh
On Nov 22, 2010, at 5:38 AM, A. S. wrote: Hi! at the company I work for I'd like to propose introducing Python to replace the hopelessly outdated SAS scripts. SQLAlchemy seems like a good option for SQL handling and I can imagine modules specifically tailored to our needs. However, the

[sqlalchemy] Re: Implementing fine-grained access control

2010-11-22 Thread Dan Ellis
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

[sqlalchemy] MetaData, postgresql, and temporary tables

2010-11-22 Thread Jon Nelson
I have an app where I think I'm going to want to use a TEMPORARY TABLE like this: CREATE TEMPORARY TABLE results AS SELECT .; and then do two things: 1. I need a select count(1) from that table 2. I need to be able to iterate over the rows in that table The reason I am using a TEMPORARY

Re: [sqlalchemy] Re: Implementing fine-grained access control

2010-11-22 Thread Michael Bayer
On Nov 22, 2010, at 12:21 PM, Dan Ellis wrote: 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

Re: [sqlalchemy] Implementing fine-grained access control

2010-11-22 Thread A.M.
On Nov 22, 2010, at 9:30 AM, Dan Ellis wrote: I'd like to find some way to implement access controls on mapped objects, with the following features: * Example: given a BlogPost object, only the owner, or a superuser, would be allowed to set fields such as title and body. * Example:

Re: [sqlalchemy] MetaData, postgresql, and temporary tables

2010-11-22 Thread Michael Bayer
On Nov 22, 2010, at 12:42 PM, Jon Nelson wrote: I have an app where I think I'm going to want to use a TEMPORARY TABLE like this: CREATE TEMPORARY TABLE results AS SELECT .; and then do two things: 1. I need a select count(1) from that table 2. I need to be able to iterate over

Re: [sqlalchemy] Adding business logic to Session by inheritance?

2010-11-22 Thread Torsten Landschoff
Hi Michael, Am Montag, den 22.11.2010, 11:18 -0500 schrieb Michael Bayer: Originally I added only 2 fields and 4 methods to the Session but it seems like this will grow a bit. Is it okay to add a whole bunch of methods to my Session class? Any hints how to avoid name clashes for future

Re: [sqlalchemy] Adding business logic to Session by inheritance?

2010-11-22 Thread Michael Bayer
On Nov 22, 2010, at 1:11 PM, Torsten Landschoff wrote: Hi Michael, Am Montag, den 22.11.2010, 11:18 -0500 schrieb Michael Bayer: Originally I added only 2 fields and 4 methods to the Session but it seems like this will grow a bit. Is it okay to add a whole bunch of methods to my Session

[sqlalchemy] Re: Implementing fine-grained access control

2010-11-22 Thread Dan Ellis
Thanks for those tips. InstrumentationManager sounded like the best thing, so I've gone with that idea. Here's the basic structure of it for anyone who's interested: http://pastie.textmate.org/1318179 Thanks again, Michael. -- You received this message because you are subscribed to the Google

[sqlalchemy] Re: Problems when querying the database

2010-11-22 Thread Alvaro Reinoso
Fixed it! On Nov 22, 10:14 am, Alvaro Reinoso alvrein...@gmail.com wrote: So what do you suggest to get the instance by title? I can query the database by title to get the id and then query again to get the instance by id. What do you think? On Nov 17, 1:10 pm, Michael Bayer

[sqlalchemy] Problem deleting an item

2010-11-22 Thread Alvaro Reinoso
Hello all, I have these classes: class Screen(rdb.Model): Represents the screen rdb.metadata(metadata) rdb.tablename(screens) id = Column(id, Integer, primary_key=True) title = Column(title, String(100)) .. crm = relationship(CRM,

[sqlalchemy] Quick question on fetch batch size

2010-11-22 Thread Yang Zhang
When reading objects like so (notice no `.all()`): for obj in Session().query(User): ... what's the batch size with which sqlalchemy fetches rows from the DB? (If the engine matters: for Postgresql, MySQL, and sqlite?) Thanks. -- Yang Zhang http://yz.mit.edu/ -- You received this

Re: [sqlalchemy] Problem deleting an item

2010-11-22 Thread Michael Bayer
On Nov 22, 2010, at 4:32 PM, Alvaro Reinoso wrote: Hello all, I have these classes: class Screen(rdb.Model): Represents the screen rdb.metadata(metadata) rdb.tablename(screens) id = Column(id, Integer, primary_key=True) title = Column(title,

Re: [sqlalchemy] Quick question on fetch batch size

2010-11-22 Thread Michael Bayer
On Nov 22, 2010, at 5:17 PM, Yang Zhang wrote: When reading objects like so (notice no `.all()`): for obj in Session().query(User): ... what's the batch size with which sqlalchemy fetches rows from the DB? (If the engine matters: for Postgresql, MySQL, and sqlite?) postgresql:

[sqlalchemy] Avoiding mutable column types

2010-11-22 Thread Torsten Landschoff
Hi again! Sorry for all the questions, here is another one. What I really would like to do is to read a chunk of data for a mapped instance and disseminate that into a number of attributes (not the usual one column - one attribute mapping). This could easily be done using an orm.reconstructor.

Re: [sqlalchemy] Avoiding mutable column types

2010-11-22 Thread Michael Bayer
On Nov 22, 2010, at 6:17 PM, Torsten Landschoff wrote: Hi again! Sorry for all the questions, here is another one. What I really would like to do is to read a chunk of data for a mapped instance and disseminate that into a number of attributes (not the usual one column - one attribute