Unique meta_types in a folder
Zopists, Is there anyway to create a list of unique meta_types in a folder without knowing them before hand. I would hate to pack them into a REQUEST variable throught iteration because that would take forever. Some thing like <dtml-in possible_types> <dtml-in "objectValues(_['sequence-item'])"> <dtml-var mycode> </dtml-in> </dtml-in> I am trying to let the viewer sort the view by meta_type but only have the meta_type they ask for show up. Just like the UniqueValuesfor in the Catalog only for a Folder. All my best, -- Jason Spisak 444@hiretechs.com
On Fri, 17 Mar 2000, Jason Spisak wrote:
Zopists,
Is there anyway to create a list of unique meta_types in a folder without knowing them before hand.
I would hate to pack them into a REQUEST variable throught iteration because that would take forever.
Some thing like
<dtml-in possible_types> <dtml-in "objectValues(_['sequence-item'])"> <dtml-var mycode> </dtml-in> </dtml-in>
objectValues can take a list as an argument. Assuming possible_types is a list then : <dtml-in "objectValues(possible_values)"> should work Pavlos
I am trying to let the viewer sort the view by meta_type but only have the meta_type they ask for show up. Just like the UniqueValuesfor in the Catalog only for a Folder.
All my best,
-- Jason Spisak 444@hiretechs.com
_______________________________________________ Zope-Dev maillist - Zope-Dev@zope.org http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Pavlos, I wasn't quite clear. I'm trying to get 'possible_values'. Right now the only way is to iterate through all the items in a folder and only append the unique ones. That would take a very long time. Is there a way to access the allowables defined by the "Sub Objects" tab of a Zclass? Pavlos Christoforou writes:
On Fri, 17 Mar 2000, Jason Spisak wrote:
Zopists,
Is there anyway to create a list of unique meta_types in a folder without knowing them before hand.
I would hate to pack them into a REQUEST variable throught iteration because that would take forever.
Some thing like
<dtml-in possible_types> <dtml-in "objectValues(_['sequence-item'])"> <dtml-var mycode> </dtml-in> </dtml-in>
objectValues can take a list as an argument. Assuming possible_types is a list then :
<dtml-in "objectValues(possible_values)">
should work
Pavlos
I am trying to let the viewer sort the view by meta_type but only have the meta_type they ask for show up. Just like the UniqueValuesfor in the Catalog only for a Folder.
All my best,
-- Jason Spisak 444@hiretechs.com
_______________________________________________ Zope-Dev maillist - Zope-Dev@zope.org http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Jason Spisak CIO HireTechs.com 6151 West Century Boulevard Suite 900 Los Angeles, CA 90045 P. 310.665.3444 F. 310.665.3544 Under US Code Title 47, Sec.227(b)(1)(C), Sec.227(a)(2)(B) This email address may not be added to any commercial mail list with out my permission. Violation of my privacy with advertising or SPAM will result in a suit for a MINIMUM of $500 damages/incident, $1500 for repeats.
On Fri, 17 Mar 2000, Jason Spisak wrote:
Pavlos,
I wasn't quite clear. I'm trying to get 'possible_values'. Right now the only way is to iterate through all the items in a folder and only append the unique ones. That would take a very long time. Is there a way to access the allowables defined by the "Sub Objects" tab of a Zclass?
Oops I am sorry .... I do not know whether there is a magic Zope method to return that. If not then you are right and you will have to iterate over all subobjects, like (tested): <dtml-call "REQUEST.set('tmp',{})"> <dtml-in objectValues> <dtml-call "REQUEST['tmp'].update({meta_type:''})"> </dtml-in> <dtml-return "REQUEST['tmp'].keys()"> Pavlos
Pavlos: A quick look at the source reveals none other that the "possible_meta_types" variable. I am having trouble accessing that from an instance though. The ZClass atb just calls <dtml-in possible_meta_types mapping> But when I cal that from an instance I get: Error Type: KeyError Error Value: possible_meta_types Does anyone know how to access that from an instance? All my best,
On Fri, 17 Mar 2000, Jason Spisak wrote:
Pavlos,
I wasn't quite clear. I'm trying to get 'possible_values'. Right now the only way is to iterate through all the items in a folder and only append the unique ones. That would take a very long time. Is there a way to access the allowables defined by the "Sub Objects" tab of a Zclass?
Oops I am sorry .... I do not know whether there is a magic Zope method to return that. If not then you are right and you will have to iterate over all subobjects, like (tested):
<dtml-call "REQUEST.set('tmp',{})"> <dtml-in objectValues> <dtml-call "REQUEST['tmp'].update({meta_type:''})"> </dtml-in> <dtml-return "REQUEST['tmp'].keys()">
Pavlos
Jason Spisak CIO HireTechs.com 6151 West Century Boulevard Suite 900 Los Angeles, CA 90045 P. 310.665.3444 F. 310.665.3544 Under US Code Title 47, Sec.227(b)(1)(C), Sec.227(a)(2)(B) This email address may not be added to any commercial mail list with out my permission. Violation of my privacy with advertising or SPAM will result in a suit for a MINIMUM of $500 damages/incident, $1500 for repeats.
On Fri, 17 Mar 2000, Jason Spisak wrote:
Pavlos:
A quick look at the source reveals none other that the "possible_meta_types" variable. I am having trouble accessing that from an instance though. The ZClass atb just calls
<dtml-in possible_meta_types mapping>
Jason, in the case of regular Folders such a provision can only be made if somehow Folders keep a record of all the newly added meta_types and modify it accordingly. I doubt there is such a thing but I do not know. ZClasses however are different and they need to register themselves upon creation so such a provision is natural. I have not checked the source code but this is my guess. Pavlos
On Fri, 17 Mar 2000 17:50:03 GMT, "Jason Spisak" <444@hiretechs.com> wrote:
Pavlos,
I wasn't quite clear. I'm trying to get 'possible_values'. Right now the only way is to iterate through all the items in a folder and only append the unique ones. That would take a very long time. Is there a way to access the allowables defined by the "Sub Objects" tab of a Zclass?
Yes. This will list all the meta_types that the current user has permissions to manage: <dtml-in "filtered_meta_types(AUTHENTICATED_USER)" mapping> <dtml-var name> </dtml-in> And this will list them all: <dtml-in all_meta_types mapping> <dtml-var name> </dtml-in> Both of those will do the right thing in either a folder or a ZClass ObjectManager. Toby Dickenson tdickenson@geminidataloggers.com
Jason Spisak wrote:
Zopists,
Is there anyway to create a list of unique meta_types in a folder without knowing them before hand.
I would hate to pack them into a REQUEST variable throught iteration because that would take forever.
Some thing like
<dtml-in possible_types> <dtml-in "objectValues(_['sequence-item'])"> <dtml-var mycode> </dtml-in> </dtml-in>
I am trying to let the viewer sort the view by meta_type but only have the meta_type they ask for show up. Just like the UniqueValuesfor in the Catalog only for a Folder.
All my best,
"""Tested Code Follows""" Sorting by meta_type is easy: <dtml-in "objectValues()" sort=meta_type> <dtml-var meta_type> <dtml-var title_or_id> </dtml-in objectValues> Now, I presume you build the display form a search form, or a link? If so, let's assume you assign the meta_type form variable a name of 'Type'. <dtml-in "objectValues(_['Type'])" sort=meta_type> <br> <a href="<dtml-var absolute_url>"> <dtml-var title_or_id> </a> is a <dtml-var meta_type> </dtml-in objectValues> Will display only the types in a given folder. To build that list, you could use a Python method (tested) or an External Method (untested) and do: ------------------- possibles=[] for type in self.objectValues(): if possibles.count(type.meta_type): continue else: possibles.append(type.meta_type) return possibles --------------------- In my testing, I called this "get_meta_types". to use: <dtml-in get_meta_types> <dtml-var sequence-item> </dtml-in get_meta_types> So, I have A DTML Document: <dtml-if Type> <p>Listed by type of object: <dtml-in "PARENTS[0].objectValues(_['Type'])" sort=meta_type> <br><dtml-var meta_type> <dtml-var title_or_id> <dtml-else> <p> Sorry, no matches found. </dtml-in> <dtml-else> <dtml-in get_meta_types> <br><a href=<dtml-var id>?Type=<dtml-var sequence-item url_quote>><dtml-var sequence-item></a> </dtml-in all_meta_types> </dtml-if Type> which will provide a list of possible types, authenticated by user, which when clicked upon, will give a list of objects that match that chosen meta_type. """End tested code""" Speed was just fine for me. Fit into HTML as needed,modify to suit your needs, YMMV, yadda-yadda. ;) Also, there is http://www.zope.org/Members/AlexR/SelectionLists which, while it doesn't give exactly what you are looking for, does have related items, so I referenced it. :) -- In flying I have learned that carelessness and overconfidence are usually far more dangerous than deliberately accepted risks. -- Wilbur Wright in a letter to his father, September 1900
participants (4)
-
Bill Anderson -
Jason Spisak -
Pavlos Christoforou -
Toby Dickenson