[Grok-dev] Re: Referencing objects by id

Gerard Petersen lijssies at gp-net.nl
Mon Aug 4 18:40:31 EDT 2008


Dear Martijn,

I'll snoop around in de NameChooser story indeed. Thanx for that.

I do wonder about the 'id' though. I want the customer object to have a numeric value attribute for administering relations to email correspondence, invoices, tickets, etc.

By reading your explanation on the __name__ identifier (key?) I can choose any name to uniquely identify one customer object from many in a container. Right? 

Personally I don't care about whether it's a name or a number behind the scenes, as long as it's the Customers name (and what not) that is showing on the webpage.

But since it can be anything I want, how would one then name an object's key to keep it understandable for humans (the coders that is)? 

Any best practice tips on that are much appreciated.

Thanx again!

Kind regards,

Gerard.

Martijn Faassen wrote:
> Hey,
> 
> One thing you should realize is that in Zope 3 (and therefore Grok) what 
> is called 'id' in Zope 2 is actually called __name__. We call these the 
> name in the container.
> 
> So if you do:
> 
>   container[my_id] = s = Something()
> 
> you can later retrieve the __name__ of the object in that container like 
> this:
> 
>   s.__name__
> 
> I hope that helps!
> 
> It might also be worthwhile to investigate the NameChooser story in Zope 
> 3, though that isn't strictly necessary.
> 
> Regards,
> 
> Martijn
> 
> _______________________________________________
> Grok-dev mailing list
> Grok-dev at zope.org
> http://mail.zope.org/mailman/listinfo/grok-dev
> 


More information about the Grok-dev mailing list