[Zope3-dev] Re: Make message ids into "rocks", was Re: Re: SVN:
Zope3/trunk/src/zope/ Internationalized apidoc modules description.
Dmitry Vasiliev
lists at hlabs.spb.ru
Fri Sep 3 14:26:08 EDT 2004
Philipp von Weitershausen wrote:
> I don't see the need for these dictproxies. Otherwise I agree.
> Specifically, I have something like this in mind:
>
> def keys_and_values_to_unicode(mapping):
> items = [(unicode(key), unicode(value) for key, value
> in mapping.items()]
> return dict(items)
>
> class MessageID(unicode):
>
> def __new__(cls, ustr, domain=None, default=None, mapping={}):
> self = super(MessageID, cls).__new__(cls, ustr)
> self._domain = domain
> self._default = default
> self._mapping = keys_and_values_to_unicode(mapping)
return self
>
> def domain(self):
> return self._domain
> domain = property(domain)
>
> def default(self):
> return self._default
> default = property(default)
>
> def mapping(self):
> return self._mapping.copy()
> mapping = property(mapping)
>
> def __mod__(self, mapping):
> new_mapping = self.mapping
> new_mapping.update(keys_and_values_to_unicode(mapping))
> return self.__class__(
> self,
> domain=self._domain,
> default=self._default,
> mapping=new_mapping
> )
def __mod__(self, mapping):
return MessageID(self, self._domain, self._default,
self._mapping)
--
Dmitry Vasiliev (dima at hlabs.spb.ru)
http://hlabs.spb.ru
More information about the Zope3-dev
mailing list