Django Vs Rails

Jorge Godoy godoy at ieee.org
Thu Sep 15 21:54:06 CEST 2005


Jacob Smullyan <smulloni at smullyan.org> writes:

> Granted.  Also, if the tables share structure, another option would be
> to simplify their description with inheritance.

It would be great if relationships could be mapped this way too.  Something
like ...

================================================================================
class Person(baseclassForORM):
    pk_person = PK()  # Dunno, it could be anything...
    name = String(40)
    birth_date = Date()
    sex = String(1)
    obs = Text()


Address(baseclassForORM):
    pk_address = PK()  # Dunno, it could be anything...
    person_pk = Person(pk_person) or None  # If it can be null... 
    city = String(30)
    state = String(30)


(...)

inhabitant = ''
if (addressInstance.person_pk):
    inhabitant = address.name

(...)

================================================================================

                (this is a *very bad* example, I just couldn't think of
                 something simple and better right now)

... would also be interesting but it isn't essential.  I believe it is simpler
than inheritance for the ORM tool.  Just making it easy to retrieve records
from a related "class" would be great.  This is one thing that I like with
SQLObject -- I have never used PyDO, but I'll give it a try -- and getters and
setters :-)

When you go to the field of ORDBMS, it gets even more complicated, since you
can have inheritance on the database side as well...


Ah!  Of course one should not forget of mapping views as well. :-)  Having
some way to create logic to update the view is nice if the selected database
doesn't support it (e.g. with rules when using PostgreSQL).


But then, I'm far out of Python with this message :-)  Sorry.

-- 
Jorge Godoy      <godoy at ieee.org>



More information about the Python-list mailing list