Re: [SQLObject] subclassing style classes
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
|
From: Ian B. <ia...@co...> - 2003-07-16 23:24:39
|
On Wed, 2003-07-16 at 18:14, John A. Barbuto wrote: > Hi, > > I'm using SQLObject for a new project of mine, and despite a few issues, > I'm liking it a lot better than the other alternatives I've tried. > > One problem I've noticed is regarding style classes. I want to make my > own subclass of MixedCaseUnderscoreStyle with a few tiny changes, but > the utility functions the class uses (mixedToUnder, etc) aren't > exported. I could import them manually, but that seems inelegant, so I > see two alternatives: > > 1. add the functions to the __all__ variable. > 2. create a MixIn class with these functions (now methods) that is > inherited along with the Style class. > > I attached a patch (against CVS) with does number 2. I think it's a > cleaner approach...thoughts? Are style classes just not meant to be > subclassed further? Style classes are specifically meant to be subclassed further. __all__ is there because it's nice to do from SQLObject import * without mucking up the namespace too badly. A utility function like mixedToUnder would probably only be used once in your application, so you wouldn't want it imported by default. But it's fine to import it and use it otherwise (though I guess I'm fuzzy in my use of _ to mark private functions through SQLObject, though I'm also fuzzy on just what is private). I think I had a mixin at one point, but didn't use it because mixins seem conceptually heavy where a function would do. Ian |