products/CPSonFive.old

changeset 10:16e2073e9698

Moved this monkeypatch to CPSonFive
author lregebro
date Tue, 12 Jul 2005 17:27:36 +0000
parents cab3ce84cbfa
children 9cd6679b58ce
files __init__.py
diffstat 1 files changed, 36 insertions(+), 0 deletions(-) [+]
line diff
     1.1 --- a/__init__.py
     1.2 +++ b/__init__.py
     1.3 @@ -21,3 +21,39 @@
     1.4  
     1.5  This product is the container for any reusable integration between CPS and Five.
     1.6  """
     1.7 +
     1.8 +from zope.schema.interfaces import ITitledTokenizedTerm
     1.9 +
    1.10 +# Zope3.0.0 doesn't translates dropdownboxes (that's a bug)
    1.11 +def textForValue(self, term):
    1.12 +    """Extract a string from the term.
    1.13 +
    1.14 +    The term must be a vocabulary tokenized term.
    1.15 +
    1.16 +    This can be overridden to support more complex term objects. The token
    1.17 +    is returned here since it's the only thing known to be a string, or
    1.18 +    str()able."""
    1.19 +    # XXX: This is how it should be once we start using Five 1.1, with i18n.
    1.20 +    # if ITitledTokenizedTerm.providedBy(term):
    1.21 +    #     return self.translate(term.title)
    1.22 +    # return self.translate(term.token)
    1.23 +
    1.24 +    # XXX: But with Five 1.0.x we need to call Localizer:
    1.25 +    if ITitledTokenizedTerm.providedBy(term):
    1.26 +        return self.context.context.Localizer.default(term.title)
    1.27 +    return self.context.context.Localizer.default(term.token)
    1.28 +
    1.29 +
    1.30 +def initialize(context):
    1.31 +
    1.32 +    # Zope3monkey
    1.33 +    from zope.app.form.browser.itemswidgets import ItemsWidgetBase
    1.34 +    ItemsWidgetBase.textForValue = textForValue
    1.35 +    
    1.36 +    ## Five monkey
    1.37 +    # Hm? Why? Probably this fix has been pushed into Five by now, because 
    1.38 +    # this edit.pt is exactly the same as Fives...
    1.39 +    #from Products.Five.browser import EditView
    1.40 +    #from Products.Five.pagetemplatefile import FivePageTemplateFile
    1.41 +    #EditView.generated_form = FivePageTemplateFile('edit.pt')
    1.42 +