def test_UnhandleableMinimalPath(self): from Products.CMFCore.utils import minimalpath, normalize from tempfile import mktemp weirdpath = mktemp() # we need to normalize 'cos minimalpath does, btu we're not testing # normalize in this unit test. self.assertEqual(normalize(weirdpath), minimalpath(weirdpath))
def test_UnhandleableMinimalPath( self ): from Products.CMFCore.utils import minimalpath, normalize from tempfile import mktemp weirdpath = mktemp() # we need to normalize 'cos minimalpath does, btu we're not testing # normalize in this unit test. self.assertEqual( normalize(weirdpath), minimalpath(weirdpath) )
def getCurrentKeyFormat(self, reg_key): # BBB: method will be removed in CMF 2.3 if reg_key in self._directories: return reg_key # for DirectoryViews created with CMF versions before 2.1 # a path relative to Products/ was used dirpath = reg_key.replace('\\', '/') if dirpath.startswith('Products/'): dirpath = dirpath[9:] product = ['Products'] dirparts = dirpath.split('/') while dirparts: product.append(dirparts[0]) dirparts = dirparts[1:] possible_key = _generateKey('.'.join(product), '/'.join(dirparts)) if possible_key in self._directories: return possible_key # for DirectoryViews created with CMF versions before 1.5 # this is basically the old minimalpath() code dirpath = normalize(reg_key) index = dirpath.rfind('Products') if index == -1: index = dirpath.rfind('products') if index != -1: dirpath = dirpath[index+len('products/'):] product = ['Products'] dirparts = dirpath.split('/') while dirparts: product.append(dirparts[0]) dirparts = dirparts[1:] possible_key = _generateKey('.'.join(product), '/'.join(dirparts)) if possible_key in self._directories: return possible_key raise ValueError('Unsupported key given: %s' % reg_key)
def test_normalize(self): from Products.CMFCore.utils import normalize self.assertEqual(normalize('foo/bar'), 'foo/bar') self.assertEqual(normalize('foo\\bar'), 'foo/bar')
def test_normalize(self): from Products.CMFCore.utils import normalize self.assertEqual( normalize('foo/bar'), 'foo/bar' ) self.assertEqual( normalize('foo\\bar'), 'foo/bar' )
def test_normalize(self): self.assertEqual( normalize('foo/bar'), 'foo/bar' ) self.assertEqual( normalize('foo\\bar'), 'foo/bar' )