[sqlalchemy] Re: Column __repr__ with sqlalchemy types instead of db-specific object instances?

2006-11-08 Thread jeffk

Michael Bayer wrote:
 __repr__() really annoys me because no matter what i do with it, people
 tell me im using it incorrectly.  technically, __repr__() is supposed
 to return a string that when eval'ed would return the object instance.
 which is not realistic for an object like Table since its an enormous
 construction.

 if you want to take Tables and produce some kind of string
 representation, I recommend you create yourself a SchemaVisitor...since
 __repr__() is not something id write code against in this case.

Thanks. In my limited case the __repr__ is close enough to treat it as
a string for post-processing. All I need is to replace the field type
instance with the proper constructor. These are one-off operations in
order to commit a matching sqlalchemy model for existing versioned DDL
to the repository.

Would it be useful to add __repr__() roundtripping as long-term trac
ticket?

Acknowledging that full general-case __repr__ may be impractical, if
anyone saw the ticket and had ideas for incremental improvements,
__repr__ would seem to be amenable to test cases, documented
limitations, etc.


--~--~-~--~~~---~--~~
 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] indexu-style category tree of arbitrary depth

2006-11-05 Thread jeffk

I need to implement an indexu-style category tree of arbitrary depth:

 News  Media (64)
 Arts and Humanities, Automotive, Business

 Recreation  Sports (234)
 Amusement and Theme Parks, Automotive, Aviation

 Reference (32)
 Acronyms and Abbreviations, Almanacs, Arts and Humanities

Product items with arbitrary properties will be associated with
multiple product categories. The eventual rendering will be in
TurboGears or Django, the database postgresql.

Being new to both sqlalchemy and SQL tree models, I'd like to start by
learning the proper nomenclature: What is this data structure called,
particularly in sqlalchemy parlance?

I'd imagine this is a fairly common pattern in applications built on
top of sqlalchemy. Can anyone direct me to a python/sqlalchemy
open-source project using this kind of category directory, so that I
can study their implementation? I'm hoping to properly utilize
sqlalchemy to manage parent-child relationships (especially for moving
nodes), so that I don't end up parsing a stored string path field or
anything naive.

Thanks for any suggestions.


--~--~-~--~~~---~--~~
 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Column __repr__ with sqlalchemy types instead of db-specific object instances?

2006-11-05 Thread jeffk

I have a versioned repository of SQL DDL that I'd like to convert to
versioned sqlalchemy models, using the Table(...,autoload=True)
feature.

I suspect it may be a lossy operation to do so, but in the interest of
table documentation, is there a way to render the Table.__repr__() with
for example the sqlalchemy class Integer in place of the object
instance sqlalchemy.databases.postgres.PGInteger object at ... 

  Table('product_items',
  BoundMetaData(),
  Column('id',
sqlalchemy.databases.postgres.PGInteger object at 0xb75eaf6c,
key='id',
primary_key=False,
nullable=True,
default=PassiveDefault(sqlalchemy.sql._TextClause object at
0xb75eaf8c),
onupdate=None),
  (...)

I can see from this Column's example that there would be a similar
issue with the _TextClause __repr__(). I'd need to render the python
necessary to create the column to achieve my objective.

Thanks for any advice.


--~--~-~--~~~---~--~~
 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---