Hi,

I know this is an "OLD" threat but I was searching the group to see If I was 
not the first one doing this.

I am not sure I understand very well what this threat is all about, but I want 
to extend the Column class for a different reason.

I want to add extra functionality to the Column class which is absolutely NOT 
SA related. SA functionality should not be effected though.

say I want to add a config value and some methods for rendering and validating 
screens:

def MyColumn(Column):

        def __init():
                dosomething to init

        def ExtraInfo(self):
                do_something_not_sa_related

        validation = 'someregex'


and use MyColumn in places where I normally use Column(......)

What do I need to take into account, I've done some tests and "Error hell" 
broke loose, where the errors are hidden deep inside SA so hard to overcome.

Martijn  

On Dec 11, 2008, at 16:20 , Michael Bayer wrote:

> 
> 
> On Dec 11, 2008, at 3:37 AM, Angri wrote:
> 
>> 
>> Here it is: http://www.sqlalchemy.org/trac/ticket/1244
>> 
>> Maybe it is good idea to drop some new lines in faq? Something like
>> this:
>> 
>> Q: How should I extend sqlalchemy.schema.Column?
>> A: You surely dont need it. Recommended way to achive your possible
>> needs is to write instance-factory function which decorates creation
>> of sqlalchemy.schema.Column instances.
>> 
>> Q: But I'm really need it!
>> A: Ok. To subclass Column, this is the current recipe:
>> 
>> from sqlalchemy.sql.util import Annotated, annotated_classes
>> 
>> class MyColumn(Column):
>>   ...
>> 
>> class AnnotatedMyColumn(Annotated, MyColumn):
>>   pass
>> 
>> annotated_classes[MyColumn] = AnnotatedMyColumn
>> 
>> Do not forget to put AnnotatedMyColumn in the module namespace, or
>> your schema will not be pickleable!
>> 
>> Correct me please if I am wrong somewhere and excuse me for my
>> English.
> 
> Well the AnnotatedMyColumn part is less than ideal since its an  
> internal.  the way that works could very likely change.   Creating an  
> AnnotatedXXX class *can* be automated.  the pickle thing just might be  
> a caveat we'd document or arrange for an exception to occur (like  
> putting a throw in a __getstate__ method).
> 
> --~--~---------~--~----~------------~-------~--~----~
> 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
> -~----------~----~----~----~------~----~------~--~---
> 

-- 
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