> -----Original Message-----
> From: sqlalchemy@googlegroups.com 
> [mailto:[EMAIL PROTECTED] On Behalf Of svilen
> Sent: Friday, August 31, 2007 12:40 PM
> To: sqlalchemy@googlegroups.com
> Subject: [sqlalchemy] Re: advice on modifying uniqueobject recipe
> 
> 
> On Friday 31 August 2007 19:12:20 Orest Kozyar wrote:
> > I'm fairly new to Python so am still learning about metaclasses.  I 
> > think I pretty much understand how the uniqueobject recipe at 
> > http://www.sqlalchemy.org/trac/wiki/UsageRecipes/UniqueObject
> > works, and is precisely what I'm looking for.
> >
> > Since I'd like to use this recipe with a number of 
> tables/objects in 
> > my database, I am trying to figure out how to make this recipe more 
> > generic.
> >
> > For example, let's say I have the following objects:
> >
> > 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.
> what error and why? 

When I create an instance using pet('Jack', 'dog'), I get the following
error:

__call__() takes exactly 1 argument (3 given)

If I change it to pet(name='Jack', species='dog'), it works just fine.  

Orest


--~--~---------~--~----~------------~-------~--~----~
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