2011/10/11

RichDocument SimpleAttachment Title

RichDocument 是個 content type 模組,它跟 Page 功能很像,但編輯介面提供特定欄位來上傳圖檔和檔案,這些特定欄位又搭配 SimpleAttachment 模組,讓上傳檔案的工作變得更容易擴充維護,SimpleAttachment 也是 Ploneboard 的相依模組

以前 Plone 3.x 時代,就試用過 RichDocument 和 SimpleAttachment,當時覺得成熟度不足,現在新版支援 Plone 4.x 的 blob 功能,再次試用,仍然遇到無法處理附檔中文標題的問題。

不過,它的設計概念和實作方式,是學習開發技巧時的參考,下列是幾個程式碼片段和錯誤訊息的記錄:

BooleanField('displayImages',
    default=False,
    languageIndependent=0,
    widget=ImagesManagerWidget(
        label="Display images download box"
    ),
),

BooleanField('displayAttachments',
    default=True,
    languageIndependent=0,
    widget=AttachmentsManagerWidget(
        label="Display attachments download box"
    ),
),
<tal:main-macro metal:define-macro="main"
 tal:define="text context/getText;
             images python:context.getFolderContents(
                        contentFilter = {'portal_type' : ['ImageAttachment']});
             firstImage python:images and images[0] or None;
             is_editable context/@@plone_context_state/is_editable;">
<div metal:use-macro="python:context.widget('displayImages')"/>
<div metal:use-macro="python:context.widget('displayAttachments')"/>
ERROR Zope.SiteErrorLog 1317974487.770.594350019308
 http://localhost:8080/mysite/Members/marr/my-page/richdocument_view_float
Traceback (innermost last):
  Module ZPublisher.Publish, line 126, in publish
  Module ZPublisher.mapply, line 77, in mapply
  Module ZPublisher.Publish, line 46, in call_object
  Module Shared.DC.Scripts.Bindings, line 322, in __call__
  Module Shared.DC.Scripts.Bindings, line 359, in _bindAndExec
  Module Products.CMFCore.FSPageTemplate, line 240, in _exec
  Module Products.CMFCore.FSPageTemplate, line 180, in pt_render
  Module Products.PageTemplates.PageTemplate, line 79, in pt_render
  Module zope.pagetemplate.pagetemplate, line 113, in pt_render
  Module zope.tal.talinterpreter, line 271, in __call__
  Module zope.tal.talinterpreter, line 343, in interpret
  Module zope.tal.talinterpreter, line 888, in do_useMacro
...
  Module zope.tal.talinterpreter, line 343, in interpret
  Module zope.tal.talinterpreter, line 531, in do_optTag_tal
  Module zope.tal.talinterpreter, line 513, in no_tag
  Module zope.tal.talinterpreter, line 343, in interpret
  Module zope.tal.talinterpreter, line 742, in do_insertStructure_tal
  Module Products.PageTemplates.Expressions, line 219, in evaluateStructure
  Module Products.PageTemplates.Expressions, line 264, in _handleText
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe8 in position 94:
 ordinal not in range(128)

No comments: