On Aug 9, 2009, at 9:00 PM, Andreas wrote:

>
> Hi!
>
> I was just curious, if it is possible to add a method to an ORM mapped
> object, because I'd like to assemble a string within that object.
>
> Here's what I'd like to do:
>
> class page():
>    def __init__(self, name, title, content):
>        self.name = name
>        self.title = title
>        self.content = content
>
>    def getRendered():
>        return '%s\n%s' % (self.title, self.content)
>        # well.. a bit more complicated than this, but you get the
> idea
>
> page_table = table (...)
> mapper (...)
>
> # somewhere else:
> myPage = ... # querry a page
> print(myPage.getRendered())
>
>
> The problem ist that the mapper call overwrites anything, I can't
> access getRendered the normal way. Is there an easy work'round or do I
> have to assemble the rendered output outside the object? The
> documentation doesn't say a word about this case. :(

getRendered() isn't overwritten unless you have a column or  
MapperProperty with that name (which I doubt).



--~--~---------~--~----~------------~-------~--~----~
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 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to