I am trying to simplify the way you create sprockets, because it seems
a little complicated.  I need some expert help with metaclasses.  A
little background.
SessionConfig is where you get the data from the database given the
input that comes in from the controller.  You have to call the
"getValue" function with a dictionary:  What I would like is if each
inherited version of SessionConfig would call it's parents getValue
recursively so that the return dictionary could be built up without
the developer having to explicitly call the parents getValue
function.  Here is the code, pay attention to the "ide like to get rid
of the following line of code" comment.

class SessionConfigMeta(type):
    pass
class SessionConfig(object):
    def getValue(self, **kw):
        kw = self._doGetValue(**kw)
        return kw
    def _doGetValue(self, **kw):
        return kw

#    __metaclass__ = SessionConfigMeta
#    def __new__(cls, *args, **kw):
#    i think i need something here, but i dont know what, tried lots
of things
#        return cls

class AddRecordSessionConfig(SessionConfig):
    def _doGetValue(self, **kw):
        kw['tableName'] = 'test_table'
        return kw

class EditRecordSessionConfig(AddRecordSessionConfig):
#    metadataType = FieldsMetadata

    def _doGetValue(self, **kw):
        #ide like to get rid of the following line of code:
        kw = super(EditRecordSessionConfig, self)._doGetValue(**kw)

        kw['addedValue'] = 'my new value'
        return kw

if __name__ == '__main__':

    config = EditRecordSessionConfig()
    kw = {'a':'1', 'b':'2'}
    kw = config.getValue(**kw)
    print kw

Thanks guys.

-chris
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears Trunk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears-trunk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to