[Zope3-Users] Reusing Widgets

Tim Cook timothywayne.cook at gmail.com
Wed Feb 4 04:10:10 EST 2009


If I have an interface (IDvText) and a class DvText (shown below).  and
I want it to act exactly as a zope.schema Textline (with some additional
attributes) then is this correct and how do I (where do I find how to)
register/add to the TextLine widget?  Apologies for the line wraps.

******************************************************
from zope.schema import TextLine,Text,List,Dict,URI,Object
from zope.i18nmessageid.message import MessageFactory
from zope.interface import Interface

from interfaces.codephrase import ICodePhrase
from oship.openehr.rm.support.identification.interfaces.objectref import
IObjectRef

_ = MessageFactory('oship')

class IDvText(Interface):
    """
    blah blah!
    """
    
    value = TextLine(
        title = _(u"Value"),
        description = _(u"""Displayable rendition of the item,
regardless of its underlying structure. For DV_CODED_TEXT, this is the
rubric of the complete term as provided by the terminology service. No
carriage returns, line feeds, or other non-printing characters
permitted."""),
    )
    
    mappings=List(
        value_type=Object(schema=IObjectRef),
        title = _(u"Mappings"),
        description = _(u"""A list of MappingTerm,terms from other
terminologies most closely matching this term, typically used where the
originator (e.g.   pathology lab) of information uses a local
terminology but also supplies one or more equivalents from wellknown
terminologies (e.g. LOINC). The list contents should be of the type
TermMapping"""),
        required = False,
        )
    
    formatting = Text(
        title = _(u"Formatting"),
        description = _(u"""A format string of the form "name:value;
name:value...", e.g. "font-weight : bold; font-family : Arial;
font-size : 12pt;". Values taken from W3C CSS2 properties lists
"background" and "font"."""),
        required = False
        )
    
    hyperlink = URI(
        title = _(u"Hyperlink"),
        description = _(u"""Optional link sitting behind a section of
plain text or coded term item as type DvUri."""),
        required = False
        )
    
    language = Object(
        schema = ICodePhrase,
        title = _(u"Language"),
        description = _(u"""Optional indicator of the localised language
in which the value is written. Coded from openEHR Code Set "languages".
Only used when either the text object is in a different language from
the enclosing ENTRY, or else the text object is being used outside of an
ENTRY or other enclosing structure which indicates the language."""),
        required = False
        )
    
    encoding = Object(
        schema = ICodePhrase,
        title = _(u"Encoding"),
        description = _(u"""Name of character encoding scheme in which
this value is encoded. Coded from openEHR Code Set "character sets".
Unicode is the default assumption in openEHR, with UTF-8 being the
assumed encoding. This attribute allows for variations from these
assumptions."""),
        required = False
        )         



******************************************************
from zope.interface import implements
from zope.i18nmessageid.message import MessageFactory
from zope.schema import TextLine

from interfaces.dvtext import IDvText

_ = MessageFactory('oship')


class DvText(TextLine):
    """
   blah blah!
    """

    implements(IDvText)
    
    def __init__(self, value, mappings=None, formatting=None,
hyperlink=None, language=None, encoding=None):
        self.value = value
        self.mappings = mappings
        self.formatting = formatting
        self.hyperlink = hyperlink
        self.language = language
        self.encoding = encoding
************************************************************** 



-------------- next part --------------
A non-text attachment was scrubbed...
Name: oe_trick.png
Type: image/png
Size: 7092 bytes
Desc: not available
Url : http://mail.zope.org/pipermail/zope3-users/attachments/20090204/1a62c768/attachment.png 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://mail.zope.org/pipermail/zope3-users/attachments/20090204/1a62c768/attachment.bin 


More information about the Zope3-users mailing list