2011-08-09 2 views
2

ReferenceField가있는 사용자 지정 콘텐츠 형식을 만들었습니다. allowed_types를 Document 또는 Folder와 같은 기본 콘텐츠 유형으로 설정하면 저장 또는 다시 색인 할 때 아무런 문제가 발생하지 않습니다. 그러나 allowed_types를 다른 사용자 지정 콘텐츠 형식으로 설정하면 매우 이상한 오류가 발생합니다. ReferenceField에서 UID를 설정할 수 있으며 base_view가 중단되지 않는 것으로 보입니다. 그러나 객체를 저장하거나 다시 색인 할 수 없습니다.ReferenceField가 AttributeError를 발생시킵니다. 'function'개체에 사용자 지정 콘텐츠 형식에 '__of__'특성이 없습니다.

사용 : 플론 (Plone) 4.0.1 조프 2.12.11 파이썬 2.6.5 (r265 : 79063 년 11 월 (21) 2010 11시 58분 21초)

[GCC 4.2.1 (Apple Inc.의 5664 건설)]를

아이디어가 있으십니까? ipzope에서

atapi.ReferenceField(
    'issue_source', 
    storage=atapi.AnnotationStorage(), 
    widget=atapi.ReferenceWidget(
     label=_(u"Issue Source"), 
     description=_(u"Please select the source document to which this issue corresponds."), 
    ), 
    required=True, 
    relationship='issue_issue_source', 
    allowed_types=('Source Document'), # specify portal type names here ('Example Type',) 
    multiValued=False,   #One to One relationship 
), 

:

>>> issue 
<Issue at /Plone/Members/test_user2/test-issue> 
>>> issue.isReferenceable 
1 
>>> source_document 
<SourceDocument at /Plone/test-folder/test-doc> 
>>> issue.setIssue_source(source_document.UID()) 
>>> issue.getIssue_source() 
<SourceDocument at /Plone/test-folder/test-doc> 
>>> source_document 
<SourceDocument at /Plone/test-folder/test-doc> 
>>> issue.reindexObject() 
> /Applications/Plone/plone-site/eggs/Products.CMFDynamicViewFTI-4.0-py2.6.egg/Products/CMFDynamicViewFTI/browserdefault.py(77)__call__() 
    76   context = aq_inner(self) 
---> 77   template = template.__of__(context) 
    78   return template(context, context.REQUEST) 
ipdb> quit 
------------------------------------------------------------ 
Traceback (most recent call last): 
    File "<ipython console>", line 1, in <module> 
    File "/Applications/Plone/plone-site/eggs/Products.Archetypes-1.6.3-py2.6.egg/Products/Archetypes/CatalogMultiplex.py", line 123, in reindexObject 
    c.catalog_object(self, url, idxs=lst) 
    File "/Applications/Plone/plone-site/eggs/Plone-4.0.1-py2.6.egg/Products/CMFPlone/CatalogTool.py", line 287, in catalog_object 
    update_metadata, pghandler=pghandler) 
    File "/Applications/Plone/plone-site/eggs/Products.PDBDebugMode-1.3.1-py2.6.egg/Products/PDBDebugMode/zcatalog.py", line 20, in catalog_object 
    update_metadata=update_metadata, pghandler=pghandler) 
    File "/Applications/Plone/plone-site/eggs/Zope2-2.12.11-py2.6-macosx-10.4-x86_64.egg/Products/ZCatalog/ZCatalog.py", line 529, in catalog_object 
    update_metadata=update_metadata) 
    File "/Applications/Plone/plone-site/eggs/Zope2-2.12.11-py2.6-macosx-10.4-x86_64.egg/Products/ZCatalog/Catalog.py", line 348, in catalogObject 
    self.updateMetadata(object, uid) 
    File "/Applications/Plone/plone-site/eggs/Zope2-2.12.11-py2.6-macosx-10.4-x86_64.egg/Products/ZCatalog/Catalog.py", line 278, in updateMetadata 
    newDataRecord = self.recordify(object) 
    File "/Applications/Plone/plone-site/eggs/Zope2-2.12.11-py2.6-macosx-10.4-x86_64.egg/Products/ZCatalog/Catalog.py", line 417, in recordify 
    if(attr is not MV and safe_callable(attr)): attr=attr() 
    File "/Applications/Plone/plone-site/eggs/Products.CMFDynamicViewFTI-4.0-py2.6.egg/Products/CMFDynamicViewFTI/browserdefault.py", line 77, in __call__ 
    template = template.__of__(context) 
AttributeError: 'function' object has no attribute '__of__' 

나는 약간 다른 오류 메시지가 얻을 웹을 통해 저장을 클릭하면 : 이것은 참으로 이상한 보인다

2011-08-09 15:19:16 ERROR Zope.SiteErrorLog 1312895956.510.252592718824 http://127.0.0.1:8080/Plone/Members/test_user2/test-doc/atct_edit 
Traceback (innermost last): 
    Module ZPublisher.Publish, line 127, in publish 
    Module ZPublisher.mapply, line 77, in mapply 
    Module Products.PDBDebugMode.runcall, line 70, in pdb_runcall 
    Module ZPublisher.Publish, line 47, in call_object 
    Module Products.CMFFormController.FSControllerPageTemplate, line 91, 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 77, in mapply 
    Module ZPublisher.Publish, line 47, in call_object 
    Module Products.CMFFormController.FSControllerPythonScript, line 107, in __call__ 
    Module Products.CMFFormController.ControllerBase, line 231, in getNext 
    Module Products.CMFFormController.Actions.TraverseTo, line 38, in __call__ 
    Module ZPublisher.mapply, line 77, in mapply 
    Module ZPublisher.Publish, line 47, in call_object 
    Module Products.CMFFormController.FSControllerPythonScript, line 105, in __call__ 
    Module Products.CMFFormController.Script, line 145, in __call__ 
    Module Products.CMFCore.FSPythonScript, line 130, in __call__ 
    Module Shared.DC.Scripts.Bindings, line 324, in __call__ 
    Module Shared.DC.Scripts.Bindings, line 361, in _bindAndExec 
    Module Products.PythonScripts.PythonScript, line 344, in _exec 
    Module script, line 1, in content_edit 
    - <FSControllerPythonScript at /Plone/content_edit used for /Plone/Members/test_user2/test-doc> 
    - Line 1 
    Module Products.CMFCore.FSPythonScript, line 130, in __call__ 
    Module Shared.DC.Scripts.Bindings, line 324, in __call__ 
    Module Shared.DC.Scripts.Bindings, line 361, in _bindAndExec 
    Module Products.PythonScripts.PythonScript, line 344, in _exec 
    Module script, line 13, in content_edit_impl 
    - <FSPythonScript at /Plone/content_edit_impl used for /Plone/Members/test_user2/test-doc> 
    - Line 13 
    Module Products.Archetypes.BaseObject, line 658, in processForm 
    Module Products.Archetypes.BaseObject, line 650, in _processForm 
    - __traceback_info__: (<Issue at /Plone/Members/test_user2/test-doc>, <Field nextPreviousEnabled(boolean:rw)>, <bound method Issue.setNextPreviousEnabled of <Issue at /Plone/Members/test_user2/test-doc>>) 
    Module Products.Archetypes.CatalogMultiplex, line 123, in reindexObject 
    Module Products.CMFPlone.CatalogTool, line 287, in catalog_object 
    Module Products.PDBDebugMode.zcatalog, line 20, in catalog_object 
    Module Products.ZCatalog.ZCatalog, line 529, in catalog_object 
    Module Products.ZCatalog.Catalog, line 348, in catalogObject 
    Module Products.ZCatalog.Catalog, line 278, in updateMetadata 
    Module Products.ZCatalog.Catalog, line 417, in recordify 
    Module Products.CMFDynamicViewFTI.browserdefault, line 77, in __call__ 
AttributeError: 'function' object has no attribute '__of__' 
> /Applications/Plone/plone-site/eggs/Products.CMFDynamicViewFTI-4.0-py2.6.egg/Products/CMFDynamicViewFTI/browserdefault.py(77)__call__() 
    76   context = aq_inner(self) 
---> 77   template = template.__of__(context) 
    78   return template(context, context.REQUEST) 

답변

4

, 몇 가지 팁 :

문자열 대신 allowed_types에 튜플을 전달하십시오.

allowed_types=('Source Document',), 

카탈로그 색인 ID와 일치하는 ID를 가진 콘텐츠 항목이 없는지 확인하십시오. 또한 getIssue_source을 색인화하지 말고 꼭 필요한 경우 getRawIssue_source을 사용하십시오. 참조 필드는 실제 내용 객체를 반환하므로 일반 접근자는 카탈로그에 실제 내용 객체를 저장합니다. 나중에 많은 놀라움과 문제가 발생할 것입니다. 원시 접근자는 다음과 같은 카탈로그 쿼리에서 사용할 수있는 uuid 또는 uuid 목록을 반환합니다.

query = {'UID': uids} 
brains = catalog(query) 
+0

죄송합니다. 고마워, 이거 야! 궁극적으로 multiValued = True로 설정하기로 결정했는데, 1 개의 이슈가 많은 잠재적 인 소스 문서를 참조 할 수 있다고 생각했기 때문입니다. – waldopat

관련 문제