[Grok-dev] Re: Referencing objects by id
lijssies at gp-net.nl
Mon Aug 4 18:40:31 EDT 2008
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.
Martijn Faassen wrote:
> 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
> I hope that helps!
> It might also be worthwhile to investigate the NameChooser story in Zope
> 3, though that isn't strictly necessary.
> Grok-dev mailing list
> Grok-dev at zope.org
More information about the Grok-dev