[Zope3-dev] There's something wrong with having message ids in
schemas
Stephan Richter
srichter at cosmos.phy.tufts.edu
Thu Dec 9 09:15:17 EST 2004
On Thursday 09 December 2004 08:55, Martijn Faassen wrote:
> Wouldn't it be possible to remove the whole message id story from this
> layer, and have the presentation layer create a message id from the
> underlying title and description? If you really want to have an explicit
> message id different from the literal text, you'd need to specify it
> somewhere else, but in Infrae's experience explicit message ids tend to
> be more pain than they're worth anyway.
I wish we could use such an approach, but there are two problems. How do we
know which attributes should be message ids and which should not? Also, we
still need to specify the domain.
I personally really like the ZCML approach. There we never worry about I18n,
except that we have to specify a domain; this requirement we could actually
remove by always providing a default domain.
In ZCML, we use the directive schema to specify which fields should be
translatable. Maybe we can use the same approach for Python. Currently we
have:
>>> class IField(IAttribute):
...
... title = TextLine(...)
... description = Text(...)
But what, if we would write:
>>> class IField(IAttribute):
...
... title = MessageId(...)
... description = MessageId(...)
Then the `Field` class can ensure that all message id field values will be
message ids:
>>> class Field(Attribute):
...
... def __init__(self, title, description):
... self.title = IField['title'].fromUnicode(title)
... self.description = IField['title'].fromUnicode(description)
Then we can use the Field without passing in message ids explictely.
The declaration
>>> class IFoo(Interface):
...
... bar = Field(
... title="Bar",
... description="This is a Bar")
would be equivalent to todays spelling of
>>> from zope.app.i18n import ZopeMessageIdFactory as _
>>> class IFoo(Interface):
...
... bar = Field(
... title=_("Bar"),
... description=_("This is a Bar"))
Here is the catch though. `zope.schema` would still depend on
`zope.i18nmessageid`. But the benefit is that only `zope.schema` would need
some code to handle the case when the `zope.i18nmessageid` code is not
available.It would definitely free all `zope.*` packages of the explicit
`zope.i18nmessageid` dependency.
Regards,
Stephan
--
Stephan Richter
CBU Physics & Chemistry (B.S.) / Tufts Physics (Ph.D. student)
Web2k - Web Software Design, Development and Training
More information about the Zope3-dev
mailing list