[Grok-dev] Problem with a container
Uli Fouquet
uli at gnufix.de
Fri Jun 12 11:44:11 EDT 2009
Hi there,
rockaroundtheclock wrote:
> I'm new to Grok, and have a simple problem:
>
> I got a container in a module "xyz" called "Times". The container contains a
> list of Objects (Instances of a class). With "for x in
> self.context.values()" , I can access the objects of the container without
> problems,
> but if I try to do that in another module (let's say "abc" + import of the
> first module "xyz"), I'm unable to access the objects in the container
> (tried with "xyz.Times.values()").
>
> I recieve following error:
>
> TypeError: unbound method values() must be called with Times instance as
> first argument (got nothing instead)
>
> Any Idea, or tip how to acces values of a container from outside the module
> the container-class belongs to?
You're mixing up classes and instances of classes here. `values()`
operates on _instances_ of `Times`.
You can do:
mytimes = Times()
mytimes.values()
or, within a method of class `Times`:
self.values()
or, if `context` contains an instance of `Times`:
context.values()
You cannot do:
Times.values()
as `values()` is not a classmethod.
Hope that helps,
--
Uli
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Dies ist ein digital signierter Nachrichtenteil
Url : http://mail.zope.org/pipermail/grok-dev/attachments/20090612/07acf598/attachment.bin
More information about the Grok-dev
mailing list