Changeset 3002 in products
- Timestamp:
- Nov 11, 2010 5:26:00 PM (13 years ago)
- Location:
- quintagroup.plonegooglesitemaps/trunk
- Files:
-
- 9 edited
- 4 copied
Legend:
- Unmodified
- Added
- Removed
-
quintagroup.plonegooglesitemaps/trunk
- Property svn:mergeinfo
-
old new 1 /quintagroup.plonegooglesitemaps/branches/blacklist:2909-3000 1 2 /quintagroup.plonegooglesitemaps/branches/migratioin_product:2826-2839 2 3 /quintagroup.plonegooglesitemaps/branches/plone4:2549-2553
-
- Property svnmerge-integrated changed from /quintagroup.plonegooglesitemaps/branches/blacklist:1-3923 /quintagroup.plonegooglesitemaps/branches/migratioin_product:1-3879 /quintagroup.plonegooglesitemaps/branches/plone4:1-3593 /quintagroup.plonegooglesitemaps/branches/test_refactoring:1-3576 to /quintagroup.plonegooglesitemaps/branches/blacklist:1-4040 /quintagroup.plonegooglesitemaps/branches/migratioin_product:1-3879 /quintagroup.plonegooglesitemaps/branches/test_refactoring:1-3576 /quintagroup.plonegooglesitemaps/branches/plone4:1-3593
- Property svn:mergeinfo
-
quintagroup.plonegooglesitemaps/trunk/docs/HISTORY.txt
r2848 r3002 1 1 Changelog 2 2 ========= 3 4 1.6.0 (2010-10-11) 5 ------------------ 6 7 * Replaced hardcoded filtering to pluggable architecture, 8 with default "id" and "path" filters. 9 [mylan] 10 * Updated tests, added filtering doctests, 11 [mylan] 12 3 13 4 14 1.5.6 (2010-09-22) -
quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/browser/commonview.py
r2742 r3002 1 1 from string import find 2 2 from zope.interface import implements, Interface, Attribute 3 from zope.component import queryMultiAdapter 3 4 4 5 from Acquisition import aq_inner, aq_parent … … 7 8 8 9 from quintagroup.plonegooglesitemaps import qPloneGoogleSitemapsMessageFactory as _ 10 from quintagroup.plonegooglesitemaps.interfaces import IBlackoutFilter 9 11 from quintagroup.plonegooglesitemaps.browser.utils import additionalURLs, applyOperations 10 12 … … 68 70 result = [] 69 71 objects = self.getFilteredObjects() 70 blackout_list = self.context.getBlackout_list()71 72 reg_exps = self.context.getReg_exp() 72 73 73 brain_url_map = applyOperations([ob for ob in objects 74 if (ob.getId not in blackout_list)], 75 reg_exps) 76 74 brain_url_map = applyOperations(self.getBOFiltered(objects), reg_exps) 77 75 # Prepare dictionary for view 78 76 for url, b in brain_url_map.items(): … … 82 80 self.num_entries = len(result) 83 81 return result 82 83 def getBOFiltered(self, objects): 84 """Return black-out filtered objects 85 Every record in blackout_list filter should follow the spec: 86 [<filter name>:]<filter arguments> 87 For example: 88 1| index.html 89 2| id:index.html 90 3| path:/folder_1_level/obj_in_folder 91 4| path:./folder_near_sitemap/obj_in_folder 92 5| foo_filter:arg-1, arg-2 93 94 1->used default "id" filter - remove "index.html" objects; 95 2->explicit "id" filter - remove "index.html" objects; 96 3->"path" filter - remove /folder_1_level/obj_in_folder object, 97 path from the root of the plone site; 98 4->same to 3), but path get from the folder, where sitemap is located; 99 5->filter name is "foo_filter" (must be registered IBlackoutFilter, 100 named "foo_filter"), which get filter arguments: arg-1, arg-2 101 102 Detailed explanation look in filters.txt doctest. 103 """ 104 blackout_list = self.context.getBlackout_list() 105 for frec in blackout_list: 106 fspec = frec.split(":", 1) 107 fargs = fspec.pop() 108 fname = fspec and fspec.pop() or "id" 109 fengine = queryMultiAdapter((self.context, self.request), 110 interface=IBlackoutFilter, name=fname) 111 if fengine: 112 objects = list(fengine.filterOut(objects, fargs)) 113 return objects 84 114 85 115 def updateRequest(self): -
quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/configure.zcml
r2746 r3002 9 9 <include package="quintagroup.catalogupdater" /> 10 10 <include package="archetypes.schemaextender" /> 11 <include package="plone.browserlayer" /> 11 12 12 13 <five:registerPackage package="." initialize=".initialize" /> … … 29 30 /> 30 31 32 <!-- Register default filters --> 33 <adapter 34 for="* 35 zope.publisher.interfaces.browser.IBrowserRequest" 36 factory=".filters.IdBlackoutFilter" 37 name="id" 38 permission="zope.Public" /> 39 40 <adapter 41 for="* 42 zope.publisher.interfaces.browser.IBrowserRequest" 43 factory=".filters.PathBlackoutFilter" 44 name="path" 45 permission="zope.Public" /> 46 47 31 48 </configure> -
quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/content/sitemap.py
r2538 r3002 2 2 """ 3 3 4 import string 4 5 from zope.interface import implements, directlyProvides 5 6 … … 61 62 widget=atapi.LinesWidget( 62 63 label=_(u"Blackout entries"), 63 description=_(u"The objects with the given ids will not be " \ 64 u"included in sitemap."), 64 description=_( 65 u"Objects which match filter condition will be excluded from the sitemap." \ 66 u"Every record should follow the spec: [<filter name>:]<filter arguments>."\ 67 u" By default there are \"id\" and \"path\" filters (\"id\" used if filter"\ 68 u" name not specified). There is possibility to add new filters. "\ 69 u"Look into README.txt of the quintagroup.plonegooglesitemaps package."), 65 70 ), 66 71 ), … … 159 164 self.getField('pingTransitions').set(self, value) 160 165 166 def setBlackout_list(self, value, **kw): 167 """Clean-up whitespaces and empty lines.""" 168 val = filter(None, map(string.strip, value)) 169 self.getField('blackout_list').set(self, val) 170 171 161 172 atapi.registerType(Sitemap, PROJECTNAME) -
quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/interfaces.py
r2841 r3002 21 21 class IGoogleSitemapsLayer(ILocalBrowserLayerType): 22 22 """Marker interface that defines browser layer for the package.""" 23 24 class IBlackoutFilter(Interface): 25 """Base interface for filter adapter.""" 26 27 def filterOut(fdata, fargs): 28 """Filter out fdata by passed arguments in kwargs. 29 * fdata (list/tuple) - data for filtering 30 (list of catalog brains). 31 * fargs (string) - is key for filtering. 32 Return list/tuple like object without filtered out items. 33 """ 34 -
quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/tests/base.py
r2841 r3002 32 32 from quintagroup.plonegooglesitemaps.interfaces import IGoogleSitemapsLayer 33 33 34 from collective.testcaselayer.ptc import BasePTCLayer, ptc_layer 35 34 36 quintagroup.plonegooglesitemaps.config.testing = 1 35 37 quintagroup.plonegooglesitemaps.config.UPDATE_CATALOG = True … … 37 39 PRODUCT = 'quintagroup.plonegooglesitemaps' 38 40 39 @onsetup40 def setup_product():41 """Set up the package and its dependencies.42 41 43 The @onsetup decorator causes the execution of this body to be 44 deferred until the setup of the Plone site testing layer. We could 45 have created our own layer, but this is the easiest way for Plone 46 integration tests. 42 class NotInstalled(BasePTCLayer): 43 """Initialize the package, without installation into portal 47 44 """ 48 fiveconfigure.debug_mode = True 49 import quintagroup.plonegooglesitemaps 50 zcml.load_config('configure.zcml', quintagroup.plonegooglesitemaps) 51 zcml.load_config('overrides.zcml', quintagroup.plonegooglesitemaps) 52 fiveconfigure.debug_mode = False 45 def afterSetUp(self): 46 fiveconfigure.debug_mode = True 47 import quintagroup.plonegooglesitemaps 48 zcml.load_config('configure.zcml', quintagroup.plonegooglesitemaps) 49 zcml.load_config('overrides.zcml', quintagroup.plonegooglesitemaps) 50 fiveconfigure.debug_mode = False 53 51 54 ztc.installPackage(PRODUCT) 52 if not ptc.PLONE31: 53 ztc.installProduct("plone.browserlayer") 55 54 56 setup_product() 57 ptc.setupPloneSite( products=(PRODUCT,)) 55 ztc.installPackage(PRODUCT) 56 57 58 class Installed(BasePTCLayer): 59 """ Install product into the portal 60 """ 61 def afterSetUp(self): 62 if not ptc.PLONE31: 63 self.addProduct("plone.browserlayer") 64 self.addProduct(PRODUCT) 65 66 class UnInstalled(BasePTCLayer): 67 """ UnInstall product from the portal 68 """ 69 def afterSetUp(self): 70 qi = getattr(self.portal, 'portal_quickinstaller', None) 71 qi.uninstallProducts(products=[PRODUCT,]) 72 73 74 NotInstalledLayer = NotInstalled([ptc_layer,]) 75 InstalledLayer = Installed([NotInstalledLayer,]) 76 UnInstalledLayer = UnInstalled([InstalledLayer,]) 58 77 59 78 … … 67 86 five's registerPackage directive not recognized on module initializing. 68 87 """ 69 layer = PloneSite70 71 88 def afterSetUp(self): 72 89 self.loginAsPortalOwner() … … 81 98 82 99 def beforeTearDown(self): 83 if self.orig_mobile_ifacesis not None:100 if getattr(self, 'orig_mobile_ifaces', None) is not None: 84 101 mobilesitemapview.MOBILE_INTERFACES = self.orig_mobile_ifaces 85 102 86 103 87 class TestCase(MixinTestCase, ptc.PloneTestCase): 88 """ For unit tests """ 104 class TestCaseNotInstalled(ptc.PloneTestCase): 105 layer = NotInstalledLayer 106 107 class TestCase(ptc.PloneTestCase, MixinTestCase): 108 layer = InstalledLayer 109 110 def afterSetUp(self): 111 ptc.PloneTestCase.afterSetUp(self) 112 MixinTestCase.afterSetUp(self) 113 114 def beforeTearDown(self): 115 ptc.PloneTestCase.beforeTearDown(self) 116 MixinTestCase.beforeTearDown(self) 89 117 90 118 91 class FunctionalTestCase(MixinTestCase, ptc.FunctionalTestCase): 92 """ For functional tests """ 119 class TestCaseUnInstalled(ptc.PloneTestCase): 120 layer = UnInstalledLayer 121 122 123 class FunctionalTestCaseNotInstalled(ptc.FunctionalTestCase): 124 layer = NotInstalledLayer 125 126 class FunctionalTestCase(ptc.FunctionalTestCase, MixinTestCase): 127 layer = InstalledLayer 93 128 94 129 def afterSetUp(self): 95 super(FunctionalTestCase, self).afterSetUp() 130 ptc.FunctionalTestCase.afterSetUp(self) 131 MixinTestCase.afterSetUp(self) 96 132 self.auth = "%s:%s" % (portal_owner, default_password) 97 133 134 def beforeTearDown(self): 135 ptc.FunctionalTestCase.beforeTearDown(self) 136 MixinTestCase.beforeTearDown(self) 137 138 class FunctionalTestCaseUnInstalled(ptc.FunctionalTestCase): 139 layer = UnInstalledLayer -
quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/tests/testSitemaps.py
r2741 r3002 76 76 self.assertEqual(isinstance(wftrans, atapi.DisplayList), True) 77 77 self.assertEqual("simple_publication_workflow#publish" in wftrans.keys(), True) 78 79 def testSettingBlackout(self): 80 bolist = ["path:./el1 "," ",""," id:index.html ","index_html"] 81 expect = ("path:./el1","id:index.html","index_html") 82 self.contentSM.edit(blackout_list=bolist) 83 value = self.contentSM.getBlackout_list() 84 self.assertTrue(value == expect, "Blackout list was not cleaned "\ 85 "up from whitespaces: %s" % str(value)) 78 86 79 87 -
quintagroup.plonegooglesitemaps/trunk/setup.py
r2842 r3002 3 3 import os 4 4 5 version = '1.5.6' 5 version = '1.6.0' 6 7 tests_require=['zope.testing', 8 'collective.testcaselayer'] 6 9 7 10 setup(name='quintagroup.plonegooglesitemaps', … … 26 29 install_requires=[ 27 30 'setuptools', 31 'plone.browserlayer', 28 32 'quintagroup.canonicalpath>=0.7', 29 33 'quintagroup.catalogupdater', … … 31 35 # -*- Extra requirements: -*- 32 36 ], 37 tests_require=tests_require, 38 extras_require=dict(tests=tests_require), 33 39 entry_points=""" 34 40 # -*- Entry points: -*- … … 37 43 target = plone 38 44 """, 39 setup_requires=["PasteScript"],40 45 paster_plugins = ["ZopeSkel"], 41 46 )
Note: See TracChangeset
for help on using the changeset viewer.