Re: creating classes with mix-ins

2009-05-12 Thread Carl Banks
On May 12, 4:45 am, samwyse wrote: > Unfortunately, 'boilerplate()' uses the handlers that I provide when > MetaBlog is instantiated. In that case, the handler functions should be attributes of the instance, not of the class. Do something like this: class MetaBlog(object): def __init__(self

Re: creating classes with mix-ins

2009-05-12 Thread samwyse
On May 11, 9:01 pm, Carl Banks wrote: > On May 11, 11:16 am, samwyse wrote: > > > Should I use a class decorator, or a metaclass? > > Here's the thing: unless you have advance knowledge of the methods > defined by self.blog, you can't get the attr_list at class definition > time, which means neit

Re: creating classes with mix-ins

2009-05-11 Thread Carl Banks
On May 11, 11:16 am, samwyse wrote: > I'm writing a class that derives it's functionality from mix-ins. > Here's the code: > >     def boilerplate(what):   # This used to be a decorator, but all of > the >         ##what = f.__name__  # function bodies turned out to be > 'pass'. >         'Validat

Re: creating classes with mix-ins

2009-05-11 Thread samwyse
On May 11, 1:16 pm, samwyse wrote: > I'm writing a class that derives it's functionality from mix-ins. While waiting, I gave a try at using class decorators. Here's what I came up with: def add_methods(*m_list, **kwds): def wrapper(klass): for m_name in m_list: def templ

creating classes with mix-ins

2009-05-11 Thread samwyse
I'm writing a class that derives it's functionality from mix-ins. Here's the code: def boilerplate(what): # This used to be a decorator, but all of the ##what = f.__name__ # function bodies turned out to be 'pass'. 'Validate the user, then call the appropriate plug-in.'