Changeset 3151 in products
- Timestamp:
- Apr 20, 2011 8:15:52 AM (13 years ago)
- Location:
- quintagroup.dropdownmenu/trunk
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
quintagroup.dropdownmenu/trunk/quintagroup/dropdownmenu/Extensions/Install.py
r2876 r3151 9 9 UNINSTALL = "profile-%s:uninstall" % PROJECT_NAME 10 10 11 11 12 def uninstall(portal, reinstall=False): 12 13 """ Uninstall this product. 13 14 14 This external method is need, because portal_quickinstaller doens't know15 what GenericProfile profile to apply when uninstalling a product.15 This external method is need, because portal_quickinstaller doens't 16 know what GenericProfile profile to apply when uninstalling a product. 16 17 """ 17 18 setup_tool = getToolByName(portal, 'portal_setup') -
quintagroup.dropdownmenu/trunk/quintagroup/dropdownmenu/__init__.py
r2876 r3151 6 6 PROJECT_NAME = "quintagroup.dropdownmenu" 7 7 logger = logging.getLogger(PROJECT_NAME) 8 -
quintagroup.dropdownmenu/trunk/quintagroup/dropdownmenu/browser/controlpanel.py
r2630 r3151 28 28 conf = self._settings() 29 29 self._overrideValue(self.widgets['show_content_tabs'], not conf[0]) 30 self._overrideValue(self.widgets['show_nonfolderish_tabs'], not conf[1]) 30 self._overrideValue(self.widgets['show_nonfolderish_tabs'], 31 not conf[1]) 31 32 32 33 def _overrideValue(self, widget, value): … … 43 44 default=term.title) 44 45 widget.items.append({'id': id, 'name': widget.name + ':list', 45 'value': term.token, 'label':label, 'checked':checked})46 'value': term.token, 'label': label, 'checked': checked}) 46 47 47 48 def _settings(self, folder=None, nonfolderish=None): -
quintagroup.dropdownmenu/trunk/quintagroup/dropdownmenu/browser/menu.py
r1319 r3151 24 24 if self._settings.content_tabs_level > 0: 25 25 self.query['path']['depth'] = self._settings.content_tabs_level 26 elif self.query['path'].has_key('depth'):26 elif 'depth' in self.query['path']: 27 27 del self.query['path']['depth'] 28 28 -
quintagroup.dropdownmenu/trunk/quintagroup/dropdownmenu/browser/viewlets.py
r2843 r3151 24 24 import copy 25 25 26 def cache_key(a,b,c): 26 27 def cache_key(a, b, c): 27 28 return c + str(time() // (60 * 60)) 29 28 30 29 31 class GlobalSectionsViewlet(common.GlobalSectionsViewlet): … … 31 33 recurse = ViewPageTemplateFile('templates/sections_recurse.pt') 32 34 33 34 35 def update(self): 35 36 # we may need some previously defined variables … … 42 43 self.tool = getToolByName(context, 'portal_actions') 43 44 self.site_url = getToolByName(context, 'portal_url')() 44 self.context_state = getMultiAdapter((self.context, self.request), 45 self.context_state = getMultiAdapter((self.context, self.request), 45 46 name="plone_context_state") 46 self.context_url = 47 self.context_url = self.context_state.is_default_page() and \ 47 48 '/'.join(self.context.absolute_url().split('/')[:-1]) or \ 48 49 self.context.absolute_url() 49 50 self.cat_sufix 50 51 self.cat_sufix = self.conf.nested_category_sufix or '' 51 52 self.cat_prefix = self.conf.nested_category_prefix or '' 52 53 # fetch actions-based tabs? … … 78 79 res = copy.deepcopy(res) 79 80 self.tabs = listtabs 80 81 81 82 # if there is no custom menu in portal tabs return 82 83 if not listtabs: 83 84 return [] 84 85 85 86 current_item = -1 86 87 delta = 1000 87 88 for info in listtabs: 88 89 if self.context_url.startswith(info['url']) and \ 89 len(self.context_url) - len(info['url']) < delta:90 delta = len(self.context_url) - len(info['url'])91 current_item = listtabs.index(info)92 self.id_chain = [] 93 90 len(self.context_url) - len(info['url']) < delta: 91 delta = len(self.context_url) - len(info['url']) 92 current_item = listtabs.index(info) 93 self.id_chain = [] 94 94 95 if current_item > -1 and current_item < len(listtabs) and \ 95 96 (listtabs[current_item]['url'] != self.site_url or \ 96 listtabs[current_item]['url'] == self.site_url and self.context_url == self.site_url): 97 self.mark_active(listtabs[current_item]['id'], listtabs[current_item]['url']) 97 listtabs[current_item]['url'] == self.site_url and \ 98 self.context_url == self.site_url): 99 100 self.mark_active(listtabs[current_item]['id'], 101 listtabs[current_item]['url']) 98 102 99 103 self._activate(res) 100 104 return res 101 105 102 106 @ram.cache(cache_key) 103 107 def prepare_tabs(self, site_url): 104 def normalize_actions(category, object, level, parent_url =None):108 def normalize_actions(category, object, level, parent_url=None): 105 109 """walk through the tabs dictionary and build list of all tabs""" 106 110 tabs = [] … … 116 120 subcat = category._getOb(subcat_id) 117 121 if IActionCategory.providedBy(subcat): 118 children = normalize_actions(subcat, object, level+1, info['url']) 119 120 parent_id = category['id'].replace(self.cat_prefix,'').replace(self.cat_sufix,'') 121 tab = {'id' : info['id'], 122 children = normalize_actions(subcat, object, 123 level + 1, 124 info['url']) 125 126 parent_id = category['id'].replace(self.cat_prefix, 127 '').replace(self.cat_sufix, '') 128 tab = {'id': info['id'], 122 129 'title': info['title'], 123 130 'url': info['url'], 124 131 'parent': (parent_id, parent_url)} 125 132 tabslist.append(tab) 126 127 tab = {'id' 133 134 tab = {'id': info['id'], 128 135 'Title': info['title'], 129 136 'Description': info['description'], … … 131 138 'show_children': len(children) > 0, 132 139 'children': children, 133 'currentItem': False, 140 'currentItem': False, 134 141 'currentParent': False, 135 142 'item_icon': {'html_tag': icon}, 136 143 'normalized_review_state': 'visible'} 137 144 tabs.append(tab) 138 return tabs 145 return tabs 139 146 tabslist = [] 140 tabs = normalize_actions(self.tool._getOb(self.conf.actions_category), aq_inner(self.context), 0) 147 tabs = normalize_actions(self.tool._getOb(self.conf.actions_category), 148 aq_inner(self.context), 0) 141 149 return tabs, tabslist 142 150 … … 150 158 self._activate(info['children']) 151 159 152 153 160 def mark_active(self, current_id, url): 154 161 for info in self.tabs: … … 156 163 self.mark_active(info['parent'][0], info['parent'][1]) 157 164 self.id_chain.append(info['url']) 158 159 160 165 161 166 def _actionInfos(self, category, object, check_visibility=1, … … 222 227 def is_plone_four(self): 223 228 """Indicates if we are in plone 4. 224 229 225 230 """ 226 pm = getToolByName(aq_inner(self.context), 'portal_migration') 231 pm = getToolByName(aq_inner(self.context), 'portal_migration') 227 232 try: 228 233 version = versionTupleFromString(pm.getSoftwareVersion()) … … 232 237 if version: 233 238 return version[0] == 4 234 -
quintagroup.dropdownmenu/trunk/quintagroup/dropdownmenu/interfaces.py
r2786 r3151 67 67 nested_category_prefix = schema.TextLine( 68 68 title=_(u"Nested category prefix"), 69 description=_(u"Prefix of category id, used to bind category with action"), 69 description=_(u"Prefix of category id, used to bind category " 70 u"with action"), 70 71 default=u"", 71 72 required=False) … … 73 74 nested_category_sufix = schema.TextLine( 74 75 title=_(u"Nested category sufix"), 75 description=_(u"Sufix of category id, used to bind category with action"), 76 description=_(u"Sufix of category id, used to bind category " 77 u"with action"), 76 78 default=u"_sub", 77 79 required=False) -
quintagroup.dropdownmenu/trunk/quintagroup/dropdownmenu/setuphandlers.py
r2876 r3151 24 24 logger.log(logging.INFO, "Unregistered \"%s\" configlet." % conf_id) 25 25 26 26 27 def cleanupRegistry(site): 27 28 registry = queryUtility(IRegistry) … … 29 30 delrecs = [r for r in registry.records.keys() if r.startswith(iprefix)] 30 31 map(registry.records.__delitem__, delrecs) 31 logger.log(logging.INFO, "Removed %s items from plone.app.registry" % delrecs) 32 logger.log(logging.INFO, 33 "Removed %s items from plone.app.registry" % delrecs) 34 32 35 33 36 def fixQIUninstallDependencies(site): … … 39 42 if qiprod: 40 43 utilities = getattr(qiprod, 'utilities', []) 41 todel = filter(lambda k:not sum(map(lambda i:PROJECT_NAME in i, k)), utilities) 44 todel = filter(lambda k: not sum(map( 45 lambda i: PROJECT_NAME in i, k)), utilities) 42 46 for u in todel: 43 47 uidx = utilities.index(u) 44 48 del utilities[uidx] 49 45 50 46 51 def uninstall(context): … … 54 59 removeConfiglet(site) 55 60 cleanupRegistry(site) 56 -
quintagroup.dropdownmenu/trunk/quintagroup/dropdownmenu/tests/base.py
r2875 r3151 20 20 #ptc.setupPloneSite() 21 21 22 22 23 class NotInstalled(BasePTCLayer): 23 24 """Initialize the package, without installation into portal … … 30 31 ztc.installPackage(PROJECT_NAME) 31 32 33 32 34 class Installed(BasePTCLayer): 33 35 """ Install product into the portal … … 35 37 def afterSetUp(self): 36 38 self.addProduct(PROJECT_NAME) 39 37 40 38 41 class UnInstalled(BasePTCLayer): … … 44 47 try: 45 48 qi = self.portal.portal_quickinstaller 46 qi.uninstallProducts(products=[PROJECT_NAME, ])49 qi.uninstallProducts(products=[PROJECT_NAME, ]) 47 50 #self._refreshSkinData() 48 51 finally: 49 52 setSecurityManager(sm) 50 53 51 NotInstalledLayer = NotInstalled([ptc_layer, ])52 InstalledLayer = Installed([NotInstalledLayer, ])53 UnInstalledLayer = UnInstalled([InstalledLayer, ])54 NotInstalledLayer = NotInstalled([ptc_layer, ]) 55 InstalledLayer = Installed([NotInstalledLayer, ]) 56 UnInstalledLayer = UnInstalled([InstalledLayer, ]) 54 57 55 58 56 59 class TestCaseNotInstalled(ptc.PloneTestCase): 57 60 layer = NotInstalledLayer 61 58 62 59 63 class TestCase(ptc.PloneTestCase): … … 65 69 alsoProvides(self.app.REQUEST, IDropDownMenuLayer) 66 70 71 67 72 class TestCaseUnInstalled(ptc.PloneTestCase): 68 73 layer = UnInstalledLayer … … 71 76 class FunctionalTestCaseNotInstalled(ptc.FunctionalTestCase): 72 77 layer = NotInstalledLayer 78 73 79 74 80 class FunctionalTestCase(ptc.FunctionalTestCase): … … 80 86 alsoProvides(self.app.REQUEST, IDropDownMenuLayer) 81 87 88 82 89 class FunctionalTestCaseUnInstalled(ptc.FunctionalTestCase): 83 90 layer = UnInstalledLayer -
quintagroup.dropdownmenu/trunk/quintagroup/dropdownmenu/tests/test_controlpanel.py
r2875 r3151 6 6 7 7 from quintagroup.dropdownmenu.interfaces import IDropDownMenuSettings 8 8 9 9 10 class RegistryTest(TestCase): … … 23 24 def test_show_icons(self): 24 25 # Check show_icons record 25 show_icons = self.registry.records[IPREFIX +'show_icons']26 show_icons = self.registry.records[IPREFIX + 'show_icons'] 26 27 27 28 self.failUnless('show_icons' in IDropDownMenuSettings) 28 self.assertEquals(self.registry[IPREFIX +'show_icons'], False)29 self.assertEquals(self.registry[IPREFIX + 'show_icons'], False) 29 30 30 31 def test_show_content_tabs(self): 31 32 # Check show_content_tabs record 32 show_content_tabs = self.registry.records[IPREFIX+'show_content_tabs'] 33 show_content_tabs = self.registry.records[ 34 IPREFIX + 'show_content_tabs'] 33 35 34 36 self.failUnless('show_content_tabs' in IDropDownMenuSettings) 35 self.assertEquals(self.registry[IPREFIX +'show_content_tabs'], True)37 self.assertEquals(self.registry[IPREFIX + 'show_content_tabs'], True) 36 38 37 39 def test_show_nonfolderish_tabs(self): 38 40 # Check show_nonfolderish_tabs record 39 41 show_nonfolderish_tabs = self.registry.records[ 40 IPREFIX +'show_nonfolderish_tabs']42 IPREFIX + 'show_nonfolderish_tabs'] 41 43 42 44 self.failUnless('show_nonfolderish_tabs' in IDropDownMenuSettings) 43 self.assertEquals(self.registry[IPREFIX +'show_nonfolderish_tabs'],45 self.assertEquals(self.registry[IPREFIX + 'show_nonfolderish_tabs'], 44 46 True) 45 47 … … 47 49 # Check content_before_actions_tabs record 48 50 content_before_actions_tabs = self.registry.records[ 49 IPREFIX +'content_before_actions_tabs']51 IPREFIX + 'content_before_actions_tabs'] 50 52 51 53 self.failUnless('content_before_actions_tabs' in IDropDownMenuSettings) 52 self.assertEquals(self.registry[ IPREFIX+'content_before_actions_tabs'],53 54 self.assertEquals(self.registry[ 55 IPREFIX + 'content_before_actions_tabs'], False) 54 56 55 57 def test_content_tabs_level(self): 56 58 # Check content_tabs_level record 57 content_tabs_level = self.registry.records[IPREFIX+'content_tabs_level'] 59 content_tabs_level = self.registry.records[ 60 IPREFIX + 'content_tabs_level'] 58 61 59 62 self.failUnless('content_tabs_level' in IDropDownMenuSettings) 60 self.assertEquals(self.registry[IPREFIX +'content_tabs_level'], 0)63 self.assertEquals(self.registry[IPREFIX + 'content_tabs_level'], 0) 61 64 62 65 def test_show_actions_tabs(self): 63 66 # Check show_actions_tabs record 64 show_actions_tabs = self.registry.records[IPREFIX+'show_actions_tabs'] 67 show_actions_tabs = self.registry.records[ 68 IPREFIX + 'show_actions_tabs'] 65 69 66 70 self.failUnless('show_actions_tabs' in IDropDownMenuSettings) 67 self.assertEquals(self.registry[IPREFIX +'show_actions_tabs'], True)71 self.assertEquals(self.registry[IPREFIX + 'show_actions_tabs'], True) 68 72 69 73 def test_actions_tabs_level(self): 70 74 # Check actions_tabs_level record 71 actions_tabs_level = self.registry.records[IPREFIX+'actions_tabs_level'] 75 actions_tabs_level = self.registry.records[ 76 IPREFIX + 'actions_tabs_level'] 72 77 73 78 self.failUnless('actions_tabs_level' in IDropDownMenuSettings) 74 self.assertEquals(self.registry[IPREFIX +'actions_tabs_level'], 0)79 self.assertEquals(self.registry[IPREFIX + 'actions_tabs_level'], 0) 75 80 76 81 def test_actions_category(self): 77 82 # Check actions_category record 78 actions_category = self.registry.records[IPREFIX +'actions_category']83 actions_category = self.registry.records[IPREFIX + 'actions_category'] 79 84 80 85 self.failUnless('actions_category' in IDropDownMenuSettings) 81 self.assertEquals(self.registry[IPREFIX +'actions_category'],86 self.assertEquals(self.registry[IPREFIX + 'actions_category'], 82 87 u"portal_tabs") 83 88 … … 85 90 # Check nested_category_prefix record 86 91 nested_category_prefix = self.registry.records[ 87 IPREFIX +'nested_category_prefix']92 IPREFIX + 'nested_category_prefix'] 88 93 89 94 self.failUnless('nested_category_prefix' in IDropDownMenuSettings) 90 self.assertEquals(self.registry[IPREFIX +'nested_category_prefix'],95 self.assertEquals(self.registry[IPREFIX + 'nested_category_prefix'], 91 96 u"") 92 97 … … 94 99 # Check nested_category_sufix record 95 100 nested_category_sufix = self.registry.records[ 96 IPREFIX +'nested_category_sufix']101 IPREFIX + 'nested_category_sufix'] 97 102 98 103 self.failUnless('nested_category_sufix' in IDropDownMenuSettings) 99 self.assertEquals(self.registry[IPREFIX +'nested_category_sufix'],104 self.assertEquals(self.registry[IPREFIX + 'nested_category_sufix'], 100 105 u"_sub") 101 106 -
quintagroup.dropdownmenu/trunk/quintagroup/dropdownmenu/tests/test_docs.py
r2872 r3151 5 5 #from zope.component import testing 6 6 from base import TestCase, ztc 7 7 8 8 9 def test_suite(): -
quintagroup.dropdownmenu/trunk/quintagroup/dropdownmenu/tests/test_installation.py
r2874 r3151 10 10 11 11 from base import * 12 CSS_RESOURCES = ["++resource++drop_down.css",] 13 DEPENDENCIES = ["plone.app.registry",] 14 CONFIGLETS = ["dropdownmenu",] 15 #REGISTRY_INTERFACE = "quintagroup.dropdownmenu.interfaces.IDropDownMenuSettings" 12 CSS_RESOURCES = ["++resource++drop_down.css", ] 13 DEPENDENCIES = ["plone.app.registry", ] 14 CONFIGLETS = ["dropdownmenu", ] 15 #REGISTRY_INTERFACE="quintagroup.dropdownmenu.interfaces.IDropDownMenuSettings" 16 16 17 17 18 class TestInstallation(TestCase): … … 24 25 def testInstalledDependencies(self): 25 26 cp = self.portal.portal_controlpanel 26 configlets = [ai['id'] for ai in cp.listActionInfos(check_permissions=0)] 27 self.assertTrue([1 for ai in configlets if ai=="plone.app.registry"], 27 configlets = [ai['id'] for ai in cp.listActionInfos( 28 check_permissions=0)] 29 self.assertTrue([1 for ai in configlets if ai == "plone.app.registry"], 28 30 'Not installed required plone.app.registry product.') 29 31 … … 36 38 def testConfiglet(self): 37 39 cp = self.portal.portal_controlpanel 38 configlets = [ai['id'] for ai in cp.listActionInfos(check_permissions=0)] 40 configlets = [ai['id'] for ai in cp.listActionInfos( 41 check_permissions=0)] 39 42 for cid in CONFIGLETS: 40 self.assertTrue([1 for ai in configlets if ai ==cid],43 self.assertTrue([1 for ai in configlets if ai == cid], 41 44 'No "%s" configlet added to plone control panel' % cid) 42 45 … … 48 51 registry = queryUtility(IRegistry) 49 52 afield = "show_content_tabs" 50 self.assertTrue(registry.records.get(IPREFIX +afield, None),53 self.assertTrue(registry.records.get(IPREFIX + afield, None), 51 54 "Not registered '%s' registry interface" % IPREFIX) 55 52 56 53 57 class TestUninstallation(TestCaseUnInstalled): … … 66 70 def testConfiglet(self): 67 71 cp = self.portal.portal_controlpanel 68 configlets = [ai['id'] for ai in cp.listActionInfos(check_permissions=0)] 72 configlets = [ai['id'] for ai in cp.listActionInfos( 73 check_permissions=0)] 69 74 for cid in CONFIGLETS: 70 self.assertFalse([1 for ai in configlets if ai==cid], 71 '"%s" configlet not uninstalled from plone control panel' % cid) 75 self.assertFalse([1 for ai in configlets if ai == cid], 76 '"%s" configlet not uninstalled '\ 77 'from plone control panel' % cid) 72 78 73 79 def testBrowserLayer(self): … … 78 84 registry = queryUtility(IRegistry) 79 85 afield = "show_content_tabs" 80 self.assertFalse(registry.records.get(IPREFIX +afield, None),86 self.assertFalse(registry.records.get(IPREFIX + afield, None), 81 87 "Not unregistered '%s' registry interface" % IPREFIX) 82 88 -
quintagroup.dropdownmenu/trunk/quintagroup/dropdownmenu/util.py
r1319 r3151 17 17 } 18 18 19 19 20 def getDropDownMenuSettings(context): 20 21 """Return dropdown menu settings""" … … 22 23 return DropDownMenuRecordsProxy(context, registry, IDropDownMenuSettings, 23 24 omitted=()) 25 24 26 25 27 class DropDownMenuRecordsProxy(RecordsProxy): … … 30 32 # override initialization to pass context for further purposes; 31 33 # yes, I know, this is badly to depend on context in utilities, 32 # but I haven't come up with some better way to proxy plone.registry yet33 # skip __setattr__34 # but I haven't come up with some better way to proxy 35 # plone.registry yet skip __setattr__ 34 36 self.__dict__['__context__'] = context 35 37 super(DropDownMenuRecordsProxy, self).__init__(registry, schema, -
quintagroup.dropdownmenu/trunk/setup.py
r3094 r3151 4 4 version = '1.2' 5 5 6 tests_require =['zope.testing',6 tests_require = ['zope.testing', 7 7 'collective.testcaselayer'] 8 8 … … 12 12 long_description=open("README.txt").read() + "\n" + 13 13 open(os.path.join("docs", "HISTORY.txt")).read(), 14 # Get more strings from http://www.python.org/pypi?%3Aaction=list_classifiers15 14 classifiers=[ 16 15 "Framework :: Plone", … … 34 33 tests_require=tests_require, 35 34 extras_require=dict(tests=tests_require), 36 test_suite ='quintagroup.dropdownmenu.tests',35 test_suite='quintagroup.dropdownmenu.tests', 37 36 entry_points=""" 38 37 [z3c.autoinclude.plugin]
Note: See TracChangeset
for help on using the changeset viewer.