Orest Kozyar wrote:
> class user(object):
>       __metaclass__ = EntitySingleton
>       def __init__(self, firstname, lastname):
>               pass
> 
> class pet(object):
>       __metaclass__ = EntitySingleton
>       def __init__(self, owner, species):
>               pass
> 
> I changed __call__ method in EntitySingleton to accept an argument list so
> it can  *args.  I tried changing it to **kwargs so I could pick up the names
> of the variables (such as "firstname" and use that to filter the query with)
> but that gave me an error.  Using
> inspect.getargvalues(inspect.currentframe()) does not seem to be able to get
> me the information I need either.  

'inspect.getargspec()' will get you the names of the positional 
arguments for the class's __init__ method.  You can then work through 
the positional values in your __call__'s *args, matching a name to each. 
  Assuming you have those argument names stashed away somewhere, maybe 
something like:

   def __call__(self, *args, **kw):
       for i, value in enumerate(args):
           kw[self.names[i]] = value
       # everything is now in kw


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to