|
|
|
|
Siggg
()
|
|
||||||||||||
|
Hey madduck,
In 2005, you hit a bug that I feel like I am hitting now. At the time, you requested some help but don't appear to have got any answer (see your 2005 email at the end of this email). Any insight since then ? Here is the bug description : I get a ZCatalogError every time I try to instantiate an item of a given type (eXtremeManagement's Project type in my case). It appears that the reason for that is that Archetypes turns the id string of the new item into an unicode before trying to update the newly created item and have it cataloged. And unicode ids aren't supported, hence the exception. Archetypes does this decoding because it can't find a "raw" attribute in the ID field. I guess ID fields should always have a "raw" attribute. I don't know why it's not here in my case. I have no idea why and what to do about this. My Project type comes from Products.eXtremeManagement 2.0rc2. Some fields (skillsProfile, ...) are added to its schema using archetypes.schemaextender 1.0. I have Products.Archetypes 1.5.10 under the hoods (Plone 3.2.1). Is this a bug from my extender ? an eXtremeManagement bug ? a schemaextender bug ? an Archetypes bug ? My traceback : Traceback (innermost last): Module ZPublisher.Publish, line 119, in publish Module ZPublisher.mapply, line 88, in mapply Module ZPublisher.Publish, line 42, in call_object Module Products.CMFFormController.FSControllerPageTemplate, line 90, in __call__ Module Products.CMFFormController.BaseControllerPageTemplate, line 28, in _call Module Products.CMFFormController.ControllerBase, line 231, in getNext Module Products.CMFFormController.Actions.TraverseTo, line 38, in __call__ Module ZPublisher.mapply, line 88, in mapply Module ZPublisher.Publish, line 42, in call_object Module Products.CMFFormController.FSControllerPythonScript, line 104, in __call__ Module Products.CMFFormController.Script, line 145, in __call__ Module Products.CMFCore.FSPythonScript, line 140, in __call__ Module Shared.DC.Scripts.Bindings, line 313, in __call__ Module Shared.DC.Scripts.Bindings, line 350, in _bindAndExec Module Products.CMFCore.FSPythonScript, line 196, in _exec Module None, line 1, in content_edit - <FSControllerPythonScript at /demo/plone00/content_edit used for /demo/plone00/some-item/project.2009-02-24.6799831396> - Line 1 Module Products.CMFCore.FSPythonScript, line 140, in __call__ Module Shared.DC.Scripts.Bindings, line 313, in __call__ Module Shared.DC.Scripts.Bindings, line 350, in _bindAndExec Module Products.CMFCore.FSPythonScript, line 196, in _exec Module None, line 13, in content_edit_impl - <FSPythonScript at /demo/plone00/content_edit_impl used for /demo/plone00/some-item/project.2009-02-24.6799831396> - Line 13 Module Products.Archetypes.BaseObject, line 663, in processForm Module Products.Archetypes.BaseObject, line 655, in _processForm - __traceback_info__: (<Project at /demo/plone00/some-item/project.2009-02-24.6799831396>, <Field skillsProfile(lines:rw)>, <function mutator at 0xe5565a4>) Module Products.Archetypes.CatalogMultiplex, line 114, in reindexObject Module Products.CMFPlone.CatalogTool, line 385, in catalog_object Module Products.CacheSetup.patch, line 100, in catalog_object Module Products.CacheSetup.patch_utils, line 6, in call Module Products.ZCatalog.ZCatalog, line 533, in catalog_object CatalogError: The object unique id must be a string. And your email at the time : > Check this out. I am trying to automate the setting of the ID for my > own product. The idea is to make the ID of the instance be the > concatenation of two other fields in the schema. So I try this: > > def setId(self, id, **kwargs): > id = 'myid' > kwargs.get('schema', self.Schema())['id'].set(self, str(id), **kwargs) > import pdb; pdb.set_trace() > > but that causes an error: > > CatalogError: The object unique id must be a string. > > The problem is that somehow, the new unique ID (the relative URL) is somehow a > Unicode string by the time it arrives at ZCatalog: > > > /usr/lib/zope2.7/lib/python/Products/ZCatalog/ZCatalog.py(524)catalog_object() > -> elif not isinstance(uid,str): > (Pdb) > > /usr/lib/zope2.7/lib/python/Products/ZCatalog/ZCatalog.py(525)catalog_object() > -> raise CatalogError('The object unique id must be a string.') > (Pdb) type(uid) > <type 'unicode'> > > I can't figure out what's going on since I explicitly use str(id) in > the call to the field's set method. Nevertheless, the ID ends up > being Unicode, which causes the uid to be Unicode. > >> /srv/zope2.7/madduck/Products/DebianBook/Erratum.py(42)setId()->None > -> kwargs.get('schema', self.Schema())['id'].set(self, str(id), **kwargs) > (Pdb) id > 'myid' > (Pdb) type(id) > <type 'str'> > (Pdb) n > --Return-- >> /srv/zope2.7/madduck/Products/DebianBook/Erratum.py(42)setId()->None > -> kwargs.get('schema', self.Schema())['id'].set(self, str(id), **kwargs) > (Pdb) type(id) > <type 'str'> > (Pdb) self.id > <type 'unicode'> > > And the reason is very simple: > >> /srv/zope2.7/madduck/Products/Archetypes/Field.py(832)set() > -> value = decode(aq_base(value), instance, **kwargs) > (Pdb) type(value) > <type 'str'> > (Pdb) n >> /srv/zope2.7/madduck/Products/Archetypes/Field.py(833)set() > -> self.getStorage(instance).set(self.getName(), instance, value, **kwargs) > (Pdb) type(value) > <type 'unicode'> > > This does look like a bug to me... if Unicode cannot be used for unique > identifiers, then the 'id' field should not be using StringField, > which may actually convert the value to Unicode first. > > -- > martin; (greetings from the heart of the sun.) > \____ echo mailto: !#^."<*>"|tr "<*> mailto:" net <at> madduck > > invalid/expired pgp subkeys? use subkeys.pgp.net as keyserver! > spamtraps: madduck.bogus@... > > philosophy: unintelligible answers to insoluble problems. ------------------------------------------------------------------------------ Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise -Strategies to boost innovation and cut costs with open source participation -Receive a $600 discount off the registration fee with the source code: SFAD http://p.sf.net/sfu/XcvMzF8H _______________________________________________ Archetypes-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/archetypes-users |
||||||||||||||
| Free Embeddable Forum Powered by Nabble | Help |