On Feb 4, 2008 4:54 PM, Alexandre da Silva <[EMAIL PROTECTED]> wrote:
>
> Hello all,
>
> it would be useful (and more clear) if we could define a synonym on a
> subclass.
>
> a little example:
>
>
> we have a Person class identifying all persons on system
>
>
> class Person(Entity):
>         name = Field(Unicode(30))
>         nickname = Field(Unicode(30))
>         primary_mail = Field(Unicode(200))
>
> and we have a class identifying just the users... something like
>
> class User(Person):
>         user_name = Field(Unicode(30))
>         real_name = Field(Unicode(30))
>         email_address = Field(Unicode(30))
>         password = Field(Unicode(12))
>
> but in this class we could be use the name and nickname instead of
> create two new columns
>
>
> the class should look like
>
> class User(Person):
>         user_name = Synonym(Person.nickname)
>         real_name = Synonym(Person.name)
>         email_address = Synonym(Person.primary_address)
>         password = Field(Unicode(12))
>
>
> so we could put a synonym for any parent class in this class.
>
> than you can ask me why to create this behavior.
> well, at moment I needed this feature because I am using turbogears,
> and I have my own (complex) person structure, and I want to subclass
> the Turbogears User class from my person class. but the framework expect
> the field names that Turbogears User class have.
> for now, I will put the synonym at my person class, but I think that
> User class is the best place to put that synonyms.

It should be possible to do and it seems like a good idea, though we'd
have to use either string column names or a function returning the
column because, for example, "Person.nickname" doesn't exist until the
Person entity is setup. And even if, in this case, you could call
setup_all() after the Person class is defined and before the User
class is defined, this would be limitative in other cases.

Would you care to try to make a patch?

-- 
Gaƫtan de Menten
http://openhex.org

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"SQLElixir" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlelixir?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to