Ticket #5560 (closed Bug: fixed)
isIDAutoGenerated fails if you have content types with underscores in the name
| Reported by: | mt | Owned by: | alecm |
|---|---|---|---|
| Priority: | minor | Milestone: | 2.5.1 |
| Component: | Infrastructure | Keywords: | |
| Cc: |
Description
this patch when applied to CMFPlone/tests/testCheckId.py
--- testCheckId.py.orig 2006-06-08 15:01:10.000000000 +0100
+++ testCheckId.py 2006-06-08 15:01:31.000000000 +0100
@@ -19,6 +19,10 @@
def testAutoGeneratedId(self):
r = self.portal.plone_utils.isIDAutoGenerated('document.2004-11-09.0123456789')
self.assertEqual(r, True)
+
+ def testAutoGeneratedIdWithUnderScores(self):
+ r = self.portal.plone_utils.isIDAutoGenerated('my_document.2004-11-09.0123456789')
+ self.assertEqual(r, True)
def testEmptyId(self):
r = self.portal.plone_utils.isIDAutoGenerated('')
causes a failure when you run
bin/zopectl test --dir Products/CMFPlone --test-file-pattern testCheckId
from your zopeinstance directory (Plone 2.5-RC1)
this patch applied to CMFPlone/utils.py
--- utils.py.orig 2006-06-08 15:02:55.000000000 +0100
+++ utils.py 2006-06-08 15:13:35.000000000 +0100
@@ -117,7 +117,7 @@
obj_type, date_created, random_number = id.split('.')
type = ' '.join(obj_type.split('_'))
# New autogenerated ids may have a lower case portal type
- if (type in portaltypes and
+ if ((type in portaltypes or obj_type in portaltypes) and
DateTime(date_created) and
float(random_number)):
return True
fixes the problem in practice (but not in the test case as there is no my_document portal_type) This is a problem if you create content types with underscores, specifically if you want _at_rename_after_creation to work
Change History
Note: See
TracTickets for help on using
tickets.

Correction, the first testcase failed because the my_document portal type didn't exist in portal_types, this test shows isIDAutoGenerated failing because of underscores
--- testCheckId.py.orig 2006-06-08 15:01:10.000000000 +0100 +++ testCheckId.py 2006-06-08 15:42:35.000000000 +0100 @@ -19,6 +19,13 @@ def testAutoGeneratedId(self): r = self.portal.plone_utils.isIDAutoGenerated('document.2004-11-09.0123456789') self.assertEqual(r, True) + + def testAutoGeneratedIdWithUnderScores(self): + self.portal.portal_types.manage_addTypeInformation('Factory-based Type Information', + id='my_document', + typeinfo_name='CMFCore: Portal Folder') + r = self.portal.plone_utils.isIDAutoGenerated('my_document.2004-11-09.0123456789') + self.assertEqual(r, True) def testEmptyId(self): r = self.portal.plone_utils.isIDAutoGenerated('')