Discussion:
[Erp5-dev] Categories by example cheat-sheet creator script
Łukasz K. Nowak
2007-05-17 09:04:50 UTC
Permalink
Hello,

For some time I'm playing a lot with portal_categories. As I wasn't able
to find reference card for functions based on categories I've created
little cheat-sheet which could be used as a reference card or training
material.

Category definition:
[{'relpath':'Title'},]

[
{'example' : 'Example'},
{'example/colour' : 'Colour'},
{'example/colour/blue' : 'Blue'},
{'example/colour/green' : 'Green'},
{'example/colour/red' : 'Red'},
{'example/size' : 'Size'},
{'example/size/large' : 'Large'},
{'example/size/large/l' : 'L'},
{'example/size/large/xl' : 'XL'},
{'example/size/large/xxl' : 'XXL'},
{'example/size/medium' : 'Medium'},
{'example/size/medium/m' : 'M'},
{'example/size/small' : 'Small'},
{'example/size/small/s' : 'S'},
{'example/size/small/xs' : 'XS'},
{'example/size/small/xxs': 'XXS'},
]

Proposed TODOs are in attached file.

Luke
--
?ukasz Nowak R&D Ventis http://www.ventis.com.pl/
tel: +48 32 768 16 85 fax: +48 32 392 10 61
``Use the Source, Luke...''

-------------- next part --------------
## Script (Python) "BaseCategory_accessorsByExample"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=
##title=
##
"""
Author: ?ukasz K. Nowak <lukasz.nowak at ventis.com.pl>

Cheat-sheet script

TODO:
- automagic creationg of categories
- implementation of filling Localizer, to show difference of *Translated* functions
- extending/reimplementation of dicts passed to functions
- some filtering
- more automagic, eg. fetch all get functions, guess cartesian-matrix of dict (dunno if it is possible from ZOSB python script)
- extend for from-object-category-accessors, http://www.erp5.org/Discussion/CategoryAccessor
"""

example_category = context.portal_categories.example

# function_list is list of tuples of name and list of dicts passed to function
function_list = [
( 'getLogicalPath', [{},{'item_method':'getId'}] ),
( 'getTranslatedLogicalPath', [{},] ),
( 'getIndentedTitle', [{},] ),
( 'getCategoryRelativeUrl', [{},] ),
( 'getRelativeUrl', [{},] ),
( 'getCategoryMemberValueList', [{},] ),
( 'getBreadcrumbList', [{},] ),
( 'getBaseCategoryId', [{},] ),
( 'getBaseCategoryUid', [{},] ),
( 'getBaseCategoryValue', [{},] ),
( 'getCategoryChildValueList', [{},{'recursive':'0'},{'include_if_child':'0'},{'is_self_excluded':1}] ),
( 'getCategoryChildRelativeUrlList', [{},] ),
( 'getCategoryChildTitleItemList', [{},] ),
( 'getCategoryChildTranslatedTitleItemList', [{},] ),
( 'getCategoryChildTitleOrIdItemList', [{},] ),
( 'getCategoryChildTitleAndIdItemList', [{},] ),
( 'getCategoryChildLogicalPathItemList', [{},] ),
( 'getCategoryChildTranslatedLogicalPathItemList', [{},] ),
( 'getCategoryChildIndentedTitleItemList', [{},] ),
( 'getCategoryChildIdItemList', [{},] ),
( 'getCategoryChildItemList', [{},] ),
( 'getCategoryMemberItemList', [{},] ),
( 'getCategoryMemberTitleItemList', [{},] ),
( 'getCategoryChildValueList', [{},] ),
]

for category in example_category.getCategoryMemberValueList():
print '%s::'%(category.getRelativeUrl(),)
for (function,invocation_list) in function_list:
print '\t%s:'%(function,)
for invocation_dict in invocation_list:
print '\t\t%s:'%(invocation_dict,)
print '\t\t\t%s'%(getattr(category,function)(**invocation_dict),)
return printed
Shresth K
2007-05-21 10:29:18 UTC
Permalink
Thanks for this one. It is really helpful.
Post by Łukasz K. Nowak
Hello,
For some time I'm playing a lot with portal_categories. As I wasn't able
to find reference card for functions based on categories I've created
little cheat-sheet which could be used as a reference card or training
material.
[{'relpath':'Title'},]
[
{'example' : 'Example'},
{'example/colour' : 'Colour'},
{'example/colour/blue' : 'Blue'},
{'example/colour/green' : 'Green'},
{'example/colour/red' : 'Red'},
{'example/size' : 'Size'},
{'example/size/large' : 'Large'},
{'example/size/large/l' : 'L'},
{'example/size/large/xl' : 'XL'},
{'example/size/large/xxl' : 'XXL'},
{'example/size/medium' : 'Medium'},
{'example/size/medium/m' : 'M'},
{'example/size/small' : 'Small'},
{'example/size/small/s' : 'S'},
{'example/size/small/xs' : 'XS'},
{'example/size/small/xxs': 'XXS'},
]
Proposed TODOs are in attached file.
Luke
--
?ukasz Nowak R&D Ventis http://www.ventis.com.pl/
tel: +48 32 768 16 85 fax: +48 32 392 10 61
``Use the Source, Luke...''
_______________________________________________
Erp5-dev mailing list
Erp5-dev at erp5.org
http://erp5.org/mailman/listinfo/erp5-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.tiolive.com/pipermail/erp5-dev/attachments/20070521/c783cbde/attachment.htm>
Loading...