[sqlalchemy] Problem with a query

2011-01-18 Thread Alvaro Reinoso
Hi all, It doesn't do the second filter with those queries: session.query(User).options(joinedload(channels)).filter(User.id == int(userId)).filter(Channel.title != zeptextstuff.txt).order_by(Channel.titleView).first() or session.query(User).join(User.channels).filter(User.id ==

[sqlalchemy] Re: Problem with one relation

2010-12-07 Thread Alvaro Reinoso
, 3:51 pm, Michael Bayer mike...@zzzcomputing.com wrote: On Dec 6, 2010, at 2:39 PM, Alvaro Reinoso wrote: Hi all, I have those two classes: class Playlist(rdb.Model):    Represents playlist. It may contain playlist items    rdb.metadata(metadata)    rdb.tablename(playlists

[sqlalchemy] Re: Problem with one relation

2010-12-07 Thread Alvaro Reinoso
...@zzzcomputing.com wrote: On Dec 7, 2010, at 10:09 AM, Alvaro Reinoso wrote: The relation is OK, one-to-many between Playlist and PlaylisItem. However, PlaylistItem can contain one Playlist or one Layout and that Playlist could be in many PlaylistItems. I know it's weird relation if I already

[sqlalchemy] Problem with one relation

2010-12-06 Thread Alvaro Reinoso
Hi all, I have those two classes: class Playlist(rdb.Model): Represents playlist. It may contain playlist items rdb.metadata(metadata) rdb.tablename(playlists) id = Column(id, Integer, primary_key=True) title = Column(title, String(50)) pending =

[sqlalchemy] Re: Weird behavior

2010-12-02 Thread Alvaro Reinoso
to that user. I think it's because of that relation. How could I avoid this? Thanks! On Dec 1, 6:35 pm, Michael Bayer mike...@zzzcomputing.com wrote: On Dec 1, 2010, at 5:46 PM, Alvaro Reinoso wrote: Hello, I have a system to manage users in my application, but I'm getting some troubles

[sqlalchemy] Re: Weird behavior

2010-12-02 Thread Alvaro Reinoso
I just fixed the error. I didn't see it before. I initialize the userGroup attribute to new UseGroup instance in one of the migration functions. Thanks! On Dec 2, 11:22 am, Michael Bayer mike...@zzzcomputing.com wrote: On Dec 2, 2010, at 11:13 AM, Alvaro Reinoso wrote: I think I see

[sqlalchemy] Weird behavior

2010-12-01 Thread Alvaro Reinoso
Hello, I have a system to manage users in my application, but I'm getting some troubles with it. Every user has to belong to a group of users. One user can only be in one group. I have those tables (inheriting from rdb.Model is basically the same thing than using sqlalchemy's declarative model)

[sqlalchemy] How can I do this relation?

2010-11-30 Thread Alvaro Reinoso
Hello, I have this table: class Region(rdb.Model): Represents one region in the layout rdb.metadata(metadata) rdb.tablename(regions) id = Column(id, Integer, primary_key=True) title = Column(title, String(50)) .. channelId =

[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] 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 mike

[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] Re: Weird error when adding a new object

2010-11-19 Thread Alvaro Reinoso
...@zzzcomputing.com wrote: looks fine to me, would need full stack trace + single script file of runnable, reproducing code, thanks. On Nov 18, 2010, at 6:37 PM, Alvaro Reinoso wrote: Hello, When trying to add a new item doing: session = session.add(mediaGroup) I got this error

[sqlalchemy] Re: Weird error when adding a new object

2010-11-19 Thread Alvaro Reinoso
access to self.__dict__['foo'].  If self is a mapped object, then thats your issue. Also note this is still an out of context cut-and-paste, if you really want me to figure it out it has to be an isolated test script. On Nov 19, 2010, at 2:49 PM, Alvaro Reinoso wrote: Ok, This is the code

[sqlalchemy] Weird error when adding a new object

2010-11-18 Thread Alvaro Reinoso
Hello, When trying to add a new item doing: session = session.add(mediaGroup) I got this error: Module sqlalchemy.orm.attributes:834 in get_collection return getattr(user_data, '_sa_adapter') class GenericBackrefExtension(interfaces.AttributeExtension): return getattr(user_data,

[sqlalchemy] Problems when querying the database

2010-11-16 Thread Alvaro Reinoso
Hi all, I have a problem when querying the database: This channel class: class Channel(rdb.Model): Represents both complex channels and trivial ones (media) rdb.metadata(metadata) rdb.tablename(channels) id = Column(id, Integer, primary_key=True) title =

[sqlalchemy] Re: Best way to get data from database

2010-11-02 Thread Alvaro Reinoso
DB requests I suspect you already would have realized that the data could easily be encoded in the original page render. On Oct 28, 4:22 pm, Alvaro Reinoso alvrein...@gmail.com wrote: Hey guys, I have a doubt. I need to get the data from the sever twice every time when I load a page, one

[sqlalchemy] Weird error when I add a new attribute to one class

2010-11-02 Thread Alvaro Reinoso
Hello, I got a weird error when I try to create a new object. Before It worked without any problem, but I got this error after adding a new attribute to the User class. This attribute is related to Screen in a relation many to many through user_screens. This is the error: InvalidRequestError:

[sqlalchemy] Best way to get data from database

2010-10-28 Thread Alvaro Reinoso
Hey guys, I have a doubt. I need to get the data from the sever twice every time when I load a page, one to render the HTML and another one to get the data for client side (javascript). So I don't know exactly what it's the best way and fastest. I was trying to implement a session object and

[sqlalchemy] Recursive problem

2010-10-25 Thread Alvaro Reinoso
Hey guys, I have a problem when I import classes from one to another. I have those classes in different modules: crm.py from CRMContactInformation import CRMContactInformation class CRM(rdb.Model): Set up crm table in the database rdb.metadata(metadata)

[sqlalchemy] Re: Recursive problem

2010-10-25 Thread Alvaro Reinoso
I solved the problem delaying the imports like: from zeppelinlib.screen.ScreenTest import Screen CRMContactInformation.id = Column(id, Integer, ForeignKey(Screen.id), primary_key=True) On Oct 25, 11:18 am, Alvaro Reinoso alvrein...@gmail.com wrote: Hey guys, I have a problem when I import

[sqlalchemy] Problems creating tables one to one relation

2010-10-25 Thread Alvaro Reinoso
Hello, I get errors when I try to create tables one to one relation. Screen contains crm and crm contains more classes. The relation is one to one between crm, so I want to use the screen id as primary key in crm. And the relation is one to one between crm and some classes, I just added one class

[sqlalchemy] Re: Problems creating tables one to one relation

2010-10-25 Thread Alvaro Reinoso
must be imported before you attempt to initialize the mappings.  If class A references B, but class B doesn't exist, you get errors like that, so importing the modules that contain both class A and B solves the issue. On Oct 25, 2010, at 2:55 PM, Alvaro Reinoso wrote: Hello, I get

[sqlalchemy] Re: Problems creating tables one to one relation

2010-10-25 Thread Alvaro Reinoso
It's fixed. I was my mistake, I didn't realize it. Thank you! On Oct 25, 5:19 pm, Michael Bayer mike...@zzzcomputing.com wrote: On Oct 25, 2010, at 4:59 PM, Alvaro Reinoso wrote: I think it should be another problem because I have a file where I initialize all the tables, so that file

[sqlalchemy] dynamic load better choice than joinedload?

2010-10-20 Thread Alvaro Reinoso
Hello, I'd like to know what the best choice is. This is what I do in my system: I'm using grok server and python on the server side; and javascript on the client side. I store all the user data in a session object and this data gets called twice, one to render the HTML on the server side and

[sqlalchemy] Re: Updating a detached object

2010-09-14 Thread Alvaro Reinoso
, Michael Bayer mike...@zzzcomputing.com wrote: On Sep 13, 2010, at 2:31 PM, Alvaro Reinoso wrote: Yes, I've done that. I doesn't work either.                    for chan in channels:                            if chan.id == channel.id:                                    chan = session.merge

[sqlalchemy] Re: Updating a detached object

2010-09-13 Thread Alvaro Reinoso
: chan.items.append(item) break Do you have any idea how I can solve this problem? or another approach? Thanks! On Sep 10, 5:09 pm, Michael Bayer mike...@zzzcomputing.com wrote: On Sep 10, 2010, at 2:57 PM, Alvaro Reinoso wrote: Hello guys, I have

[sqlalchemy] Re: Updating a detached object

2010-09-13 Thread Alvaro Reinoso
Bayer mike...@zzzcomputing.com wrote: On Sep 13, 2010, at 2:13 PM, Alvaro Reinoso wrote: If I merge the updated channel like you can see in this piece of code it's working:    def insertXML(channels, strXml):            Insert a new channel given XML string            channel = Channel

[sqlalchemy] Update a record in a table

2010-09-10 Thread Alvaro Reinoso
I have some problems when I try to update information in some tables. For example, I have this table: class Channel(rdb.Model): rdb.metadata(metadata) rdb.tablename(channels) id = Column(id, Integer, primary_key=True) title = Column(title, String(100))

[sqlalchemy] Updating a detached object

2010-09-10 Thread Alvaro Reinoso
Hello guys, I have this table: class Channel(rdb.Model): rdb.metadata(metadata) rdb.tablename(channels) id = Column(id, Integer, primary_key=True) title = Column(title, String(100)) hash = Column(hash, String(50)) runtime = Column(runtime,

[sqlalchemy] How to get read-only objects from database?

2010-08-18 Thread Alvaro Reinoso
Hello, I'd like to query the database and get read-only objects with session object. I need to save the objects in my server and use them through the user session. If I use a object outside of the function that calls the database, I get this error: DetachedInstanceError: Parent instance is not

[sqlalchemy] Re: How to link one table to itself?

2010-08-16 Thread Alvaro Reinoso
, backref=media_groups) Thanks! On Aug 13, 2:15 pm, Michael Bayer mike...@zzzcomputing.com wrote: On Aug 12, 2010, at 1:08 PM, Alvaro Reinoso wrote: Hello, I'm trying to link one table to itself. I have media groups which can contain more media group. I created a relation many to many

[sqlalchemy] Re: How to link one table to itself?

2010-08-13 Thread Alvaro Reinoso
, 8:36 pm, Michael Bayer mike...@zzzcomputing.com wrote: On Aug 12, 2010, at 5:43 PM, Alvaro Reinoso wrote: I'm trying that, but I got different error: Could not determine relationship direction for primaryjoin condition 'users.id = :id_1', on relationship User.mediaGroups. Specify

[sqlalchemy] How to link one table to itself?

2010-08-12 Thread Alvaro Reinoso
Hello, I'm trying to link one table to itself. I have media groups which can contain more media group. I created a relation many to many: media_group_groups = Table( media_group_groups, metadata, Column(groupA_id,

[sqlalchemy] Re: How to link one table to itself?

2010-08-12 Thread Alvaro Reinoso
: ArgumentError: Could not determine relationship direction for primaryjoin condition 'users.id = :id_1', on relationship User.mediaGroups. Specify the 'foreign_keys' argument to indicate which columns on the relationship are foreign. Thank you! On Aug 12, 1:08 pm, Alvaro Reinoso alvrein...@gmail.com wrote

[sqlalchemy] Re: How to link one table to itself?

2010-08-12 Thread Alvaro Reinoso
) Do I need to add something else to that table? Thanks!!! On Aug 12, 5:15 pm, Michael Bayer mike...@zzzcomputing.com wrote: On Aug 12, 2010, at 5:09 PM, Michael Bayer wrote: On Aug 12, 2010, at 4:58 PM, Alvaro Reinoso wrote: I'm still working on the solution. I've found out some

[sqlalchemy] To select a few columns in some tables related

2010-08-09 Thread Alvaro Reinoso
Hello, I have these classes: class Channel(rdb.Model): rdb.metadata(metadata) rdb.tablename(channels) id = Column(id, Integer, primary_key=True) title = Column(title, String(100)) items = relationship(MediaItem, secondary=channel_items,

[sqlalchemy] Problems with the relation one to many

2010-08-04 Thread Alvaro Reinoso
Hello, I got this error when I've tried to relate some classes: UnmappedClassError: Class 'zeppelinlib.user.UserTest.User' is not mapped I don't get errors when I have relation many-to-many. This is my file where I store all the User classes. user_channels = Table(

[sqlalchemy] Re: Problems with the relation one to many

2010-08-04 Thread Alvaro Reinoso
Solved it. I'm using grok as CMS and didn't realize I have to grok every component every time when I use it. That's why I got that error. Thanks anyway! On Aug 4, 4:27 pm, Alvaro Reinoso alvrein...@gmail.com wrote: Hello, I got this error when I've tried to relate some classes

[sqlalchemy] Re: To select only some columns from some tables using session object, relation many-to-many

2010-08-03 Thread Alvaro Reinoso
('items').filter(Item.typeItem == zeppelin/ channel).order_by(Channel.titleView).all() I just need some values many times, I don't need to retrieve the whole object. Thanks in advance! On Aug 3, 1:40 am, Kalium raymond.ma...@gmail.com wrote: On Aug 3, 8:43 am, Alvaro Reinoso alvrein

[sqlalchemy] To select only some columns from some tables using session object, relation many-to-many

2010-08-02 Thread Alvaro Reinoso
Hello, I have these classes where items (class Item) is related to channel object. Channel can contain many items: channel_items = Table( channel_items, metadata, Column(channel_id, Integer, ForeignKey(channels.id)), Column(item_id, Integer,