SA generally wants you to leave the "mapped" attributes alone. While we could build extensions into the attribute system to allow screwing around with them, it seems so far that its more straightforward to just make it easier to do the underscore thing, like you described. 0.3.0 introduces a "column_prefix" flag to Mapper so that you can stick a "_" before every mapped attribute one fell swoop.
with regards to querying, there are two options to eliminating the modified attribute name from querying. one is a synonym() function that will allow an alternate name to be used in select_by() and get_by ()..this keyword has been around for awhile (although i didnt put an "automated" version of it yet): mapper(Test, testtable, column_prefix="_", properties = { 'id':SynonymProperty('_id'), 'text':SynonymProperty('_text'), ..etc }) if you wanted to automate underscores/non-underscored synonyms, you could do something like: mapper(Test, testtable, properties = dict( [("_" + key, testtable.c.[key]) for key in testtable.c.keys()] + [(key, SynonymProperty("_" + key)) for key in testtable.c.keys()] )) the other way is to cancel out the underscore prefix during querying by using a MapperExtension that overrides get_by and select_by. all of these approaches i think are easier than making a subclassed Mapper. I could also add another mapper flag to be used in conjunction with column_prefix called "query_prefix" that just allows the "_" to be stripped during get_by/select_by operations, like the extension would do. > I'd like a way to define a 'special mapper' which reads which > additional attributes I'd like to be defined and attachs the > matching custom-defined properties to the mapped class. My Test > class would like something like that: > > > class Test(object): > _extra_column_attrs["hidden": False, "readonly":False] > _hidden_cols = ("id", ) > _readonly_cols = ("readonly",) > > My final question hence is... how can I write a custom mapper which > uses custom defined properties? I suppose I can inherit the Mapper > class and tweak it, but I tried to crawl into SA sources but it's > not to clear to me where I could change something in order to get > such an effect. > I dont understand why the Mapper needs to know about these attributes, if they are not related to database columns or other database-mapped relationships. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---