[Zope] Problem Understanding URL
I think I have a simple question about how Zope is handling requests. My current task is to understand an already-written Zope web application. One thing I can't wrap my head around is this URL: https://mysite.com/UserManagement/Users/asmithS/ Speaking in Zope terms, the UserManagement object is contained in the top-level product. In the UserManagement object, there is a Users object. That's all fine and dandy, run of the mill, acquisition/containment. However, the Users object has no asmithS object. In fact, asmithS is just a username, which makes the last field in the URL essentially a parmeter on the Users object. From examining the behavior of the webapp and the code itself, I know that the index_html method of the Users object is what is returned from this request, which is a Page Template that displays the user information based on the parameter. All of what I've said so far could be wrong, so feel free to correct me if I've mis-spoken. The problem I have is that this asmithS guy seems magical. I can't figure out how the index_html knows to be called with the username as a parameter(obviously the index_html function doesn't explicitly require the parameter). What I BELIEVE is happening: the asmithS argument is processed before the page template renders. For example, when asmithS is given, a lookup is performed on the database that adds variables to the REQUEST object such as FirstName, LastName, etc. I can't find this happening but I think it must exist. From the zpt file: td valign=top tal:content=here/LastNameDoe/td What I want to know is: How can do these URL arguments work? A more advanced question would be: how do you think these here/*** variables are being added to the context. I'm actually using Zope 2. Thanks for any help ___ Zope maillist - Zope@zope.org https://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - https://mail.zope.org/mailman/listinfo/zope-announce https://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] Problem Understanding URL
Ok I'd read about those functions a little bit in the Zope 2 book or the Developer's Guide, but they seemed like advanced techniques that I probably wouldn't need to understand. Back on topic; I ran this awesome command in the terminal: grep getitem x=$(find . *.*) and turned up some random references to getitem in some dtml code, which I judge to be insignificant. There was also one very interesting usage of __getitem__ in the python code itself, and I have to investigate the code further to understand what's going on. The function definition looks suspiciously like what I would expect to find for this 'hijacking' of control: def __getitem__(self, key): v=self._getOb(key, None) if v is not None: return v if hasattr(self, 'REQUEST'): request=self.REQUEST method=request.get('REQUEST_METHOD', 'GET') if request.maybe_webdav_client and not method in ('GET', 'POST'): return NullResource(self, key, request).__of__(self) raise KeyError, key I read this as: look up the object in the current context and return it. The only problem with this is that I don't see when the object gets placed into the proper context for the TAL statements like here/FirstName, etc. Thanks for your help already, and any continued guidance is appreciated. ___ Zope maillist - Zope@zope.org https://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - https://mail.zope.org/mailman/listinfo/zope-announce https://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] Problem Understanding URL
I don't know why these are creating new threads. And I'm sorry for the formatting on that last message. ___ Zope maillist - Zope@zope.org https://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - https://mail.zope.org/mailman/listinfo/zope-announce https://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] Problem Understanding URL
Tres, I see what you mean. You're saying that the object lookup for a request follows a pattern and that the __getitem__ function has a role in that pattern. That's fine, but even if this is returning a User object there is still a problem. I think we're beyond the point where you can help me though. The problem I'm thinking of is that I know that the /Users/asmithS URL resolves to a call to index_html method of Users which in this case is just rendering the userView. As I've said the here/Property calls are located in this user view. Could this __getitem__ load the user into the context and then still call the index_html and return the .zpt? Thanks ___ Zope maillist - Zope@zope.org https://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - https://mail.zope.org/mailman/listinfo/zope-announce https://mail.zope.org/mailman/listinfo/zope-dev )