Can I create such a thing with a dict/tuple, like the FormEncode Schema
does ? Such as in the scenario I have a database to store these
"metadata" ?

Kevin Dangoor wrote:
> I've got just a couple of minutes here and I wanted to get a message
> out. I likely won't be online again until Wednesday :(
>
> I experimented a little bit with Ian Bicking's interesting
> class/instance "thing". It's interesting because it acts like a class
> in some ways and an instance in others. Unfortunately, though it looks
> like a class when you declare it, some common "class-like" things that
> you do don't work as expected. For example,
>
> def __init__(self, someparam):
>     super(MyClass, self).__init__(someparam)
>
> super() doesn't work, because MyClass, though it looks like a class,
> is actually an instance.
>
> However, I think I've got a reasonable compromise that should make
> everyone happy. I haven't tested this *at all*, so there might be some
> gotchas. The basic idea is to leave everything the way it is now, but
> allow you to pass a class in to the decorators that deal with form
> input output. If you pass a class in, the decorator will instantiate
> it.
>
> So, the only requirement, then, is that you need to be able to
> instantiate without any parameters. (If you're using the declarative
> style, that shouldn't be a problem.)
>
> The nice thing about this is that everything works exactly as you
> would expect. If you have a class, you can do all of the normal "class
> things" when subclassing. If you use an instance instead, it behaves
> that way. Not using magic is often a good thing.
>
> The changes required to TableForm (or Form, when that logic moves to
> the base class):
> * the widgets list parameter is not required any more (but can be used
> if you're creating an instance)
> * a metaclass is needed to look through the dictionary and build the widget 
> list
>
> And, of course, the "counter" bit needs to be added to the widgets to
> maintain the ordering.
>
> I was also thinking that the widgets should probably be in a separate
> class to avoid naming issues. Like this:
>
> class MyForm(TableForm):
>     class widgets:
>         name = StringCol()
>         age = IntCol()
>     some_random_other_option = True
>
> Unfortunately, not only will I not be online until Wednesday, I'm also
> not going to be able to get any work done during this time. If you've
> got a good, useful patch, be sure to attach it to a ticket and mail
> the list about it. Elvelind can commit useful patches that come in.
>
> Kevin
>
> --
> Kevin Dangoor
> Author of the Zesty News RSS newsreader
>
> email: [EMAIL PROTECTED]
> company: http://www.BlazingThings.com
> blog: http://www.BlueSkyOnMars.com

Reply via email to