Fredrik Lundh wrote: > Dhruva Hein wrote: >> results = pc() >> <=== what is the difference between pc and pc()? > > pc refers to an object, pc() calls it. in this case, it looks like pc is > the > portal catalog, and calling the catalog returns the contents. > Unfortunately there is quite a bit going on behind the scenes here so if you don't know Plone it will be confusing:
Calling the catalog is equivalent to calling the catalog method searchResults. This performs a catalog search and if (as in this case) no other arguments are passed to it it will pick up the search parameters from the current REQUEST object. Also it will add some additional search parameters: there must be a match between the user's allowed roles or userid and the 'allowedRolesAndUsers' index, and if the user doesn't have permission to access expired content, it will add some additional parameters to constrain the search to objects after their effective date and before their expired date. <snip> > that line is equivalent to > > temp = numbers["bytype"] > temp[ctype] = num ... and since temp is a constant throughout the loop it can be extracted from the loop and given a better name. All of that code would have been clearer if the original author had simply kept a reference to the bytype and bystate dictionaries and not insisted on the extra level of indirection by accessing them through the numbers dictionary. -- http://mail.python.org/mailman/listinfo/python-list