Problem with a container

View: New views
4 Messages — Rating Filter:   Alert me  

Problem with a container

by Marcel Klapschus :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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?

Re: Problem with a container

by Souheil CHELFOUH :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I don't understand your explanation. Can you post the code ? It looks
like a simple problem, but best is to post your code so we can give
you a precise answer

2009/6/12 rockaroundtheclock <battlefox@...>:

>
> I'm net 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?
>
> --
> View this message in context: http://www.nabble.com/Problem-with-a-container-tp23995849p23995849.html
> Sent from the Grok mailing list archive at Nabble.com.
>
> _______________________________________________
> Grok-dev mailing list
> Grok-dev@...
> http://mail.zope.org/mailman/listinfo/grok-dev
>
_______________________________________________
Grok-dev mailing list
Grok-dev@...
http://mail.zope.org/mailman/listinfo/grok-dev

Re: Problem with a container

by Uli Fouquet :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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



_______________________________________________
Grok-dev mailing list
Grok-dev@...
http://mail.zope.org/mailman/listinfo/grok-dev

signature.asc (196 bytes) Download Attachment

Re: Problem with a container

by Marcel Klapschus :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thx to Uli, problem is solved ;-)

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?