[z3-checkins] r32084 - in z3/sqlos/branch/kobold-sqlos/src/sqlos: . ftests
Brian Sutherland
jinty at web.de
Fri Sep 8 15:34:45 CEST 2006
On Fri, Sep 08, 2006 at 03:10:29PM +0200, kobold at codespeak.net wrote:
> Author: kobold
> Date: Fri Sep 8 15:10:28 2006
> New Revision: 32084
>
> @@ -330,6 +332,7 @@
> implements(ISQLObjectJoinContainer)
>
> _allowed_joins = ()
> + _containers = ()
I misunderstood this the first time I read it.
You could set this in __init__ as a dict directly rather than burying
> + if not self._containers:
> + self._containers = {}
in the code below.
>
> def __getitem__(self, name):
> for j in self.sqlmeta.joins:
> @@ -338,8 +341,14 @@
> for i, container in self._allowed_joins:
> if not i.implementedBy(j.otherClass):
> continue
> - c = container()
> - c._filters = {j.joinColumn[:-3] + 'ID': self.id}
> + if name in self._containers:
> + c = self._containers[name]
> + else:
> + c = container()
> + c._filters = {j.joinColumn[:-3] + 'ID': self.id}
> + if not self._containers:
> + self._containers = {}
> + self._containers[name] = c
> return contained(c, parent=self, name=name)
> raise KeyError, name
>
> Modified: z3/sqlos/branch/kobold-sqlos/src/sqlos/ftests/joins.txt
> ==============================================================================
> --- z3/sqlos/branch/kobold-sqlos/src/sqlos/ftests/joins.txt (original)
> +++ z3/sqlos/branch/kobold-sqlos/src/sqlos/ftests/joins.txt Fri Sep 8 15:10:28 2006
> @@ -61,6 +61,11 @@
> >>> lessie.id in dogs
> False
>
> +Test the cache for the containers:
> +
> + >>> john['dogs'] == john['dogs']
> + True
> +
This does what you want it to in this case.
But in general, "is" is better when you want to make sure two objects
are the same object, rather than just equal:
john['dogs'] is john['dogs']
--
Brian Sutherland
Metropolis - "it's the first movie with a robot. And she's a woman.
And she's EVIL!!"
More information about the z3-checkins
mailing list