Thanks for reply. I want to stick to the metaclass solution. Please
verify if I understood you correctly:
class MainMeta(meta1class, meta2class):
def classmaker_init(cls, name, bases, dct):
super(meta1class, cls).__init__(name, bases, dct)
super(meta2class, cls).__init__(name, bases, dct)
both meta1class and meta2class have __init__ and are subclasses of
'type'
is that correct?
what if I have variable number of base classes? can I extract this
data somehow (without specifically writing 'meta1class' in super) and
then loop through?
forgive my incompetence, I just start to conquer the python word
Thanks
On Apr 6, 3:18 pm, Kapil Thangavelu <[email protected]> wrote:
> your probably better off creating a parallel hierarchy for soap
> serialization and then adapting the sqlalchemy types to/from it as needed.
>
> if you want to do the metaclass thing, you'll probably need to overide call
> in your synthentic metaclass and call both the base meta classes call
> methods.
>
> cheers,
>
> -kapil
>
> On Tue, Apr 6, 2010 at 2:37 AM, snf <[email protected]> wrote:
> > anyone have an idea? this prevents me from developing further.
>
> > Thank you in advance.
>
> > On Apr 1, 1:33 pm, snf <[email protected]> wrote:
> > > Hi,
>
> > > I'm trying to implement a soap interface that will allow me to pass
> > > pure sqlalchemy objects as a reponse. I'm using the declarative based
> > > table definition and a soaplib library to do that. The project is a
> > > pylons project.
>
> > > The problem is that when i do:
>
> > > from project.model.meta import Base # declarative base
> > > from soaplib.serializers.clazz import ClassSerializer
> > > from soaplib.serializers.primitive import Integer
>
> > > <quote>
> > > class Resource(Base, ClassSerializer):
>
> > > # ...field definitions follow...
>
> > > # then i define soap types of the fields
> > > class types:
> > > id = Integer
> > > subid = Integer
>
> > > </quote>
>
> > > I had a problem with multiple __metaclass__ definitions, which i
> > > overcame with this snippet:
>
> > >http://code.activestate.com/recipes/204197-solving-the-metaclass-conf...
>
> > > so I added:
>
> > > __metaclass__ = classmaker()
>
> > > after:
>
> > > class Resource(Base, ClassSerializer):
>
> > > and the problem was solved. But now in my controller, when I try to
> > > return this object:
>
> > > <quote>
> > > @soap_method(soap_str, _returns = Resource)
> > > def get(self, name):
> > > agent =
> > > db_session.query(Resource).filter(Resource.name==name).first()
> > > return agent
> > > </quote>
>
> > > I get an error:
>
> > > type object 'Resource' has no attribute 'soap_members'
>
> > > which is set by the soaplib's ClassSerializer's __metaclass__ in
> > > theory (I looked through the code). So it seems that the multiple
> > > __metaclass__ hack (mentioned above) is not firing the __call__ method
> > > of ClassSerializer's __metaclass__
>
> > > Does any one have any idea how to overcome that? Is it even possible?
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "sqlalchemy" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to
> > [email protected]<sqlalchemy%[email protected]>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/sqlalchemy?hl=en.
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" 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/sqlalchemy?hl=en.