[Zope3-Users] Re: content type name
Philipp von Weitershausen
philipp at weitershausen.de
Wed Dec 1 10:04:06 EST 2004
Tom Dossis wrote:
>> The content type interfaces correspond to portal_type/meta_type.
>> Strings (really, unicode string) are only necessary for user
>> presentation. This is covered by menu entries most of the time. If you
>> have other use cases, feel free to present them here and we'll discuss
>> them.
>
> That's it exactly - I'm after the simple string for user presentation.
>
> However my application isn't browser based, rather a gui which currently
> is a fat client in that it accesses zope3 directly. I guess it should
> probably have it's own presentation view, but I don't want to tackle
> that at this stage.
>
> In any case, a user could be viewing content other than in a browser.
> For example, in an xmlrpc based folder listing to a character terminal,
> it may be desirable to include a content type string.
>
> It seems roundabout to obtain this from a browser menu title entry.
>
...
> I was looking for a way to associate a content type string which I
> didn't think should be defined via a browser menu title...
I see what you mean now. Here's something you could do (and somethign we
could look into for Zope 3 in general):
Content type interfaces are registered as named utilities providing
IContentType (IContentType is a marker interface for IInterface, the
interface that describes interfaces). By default, the name by which they
are registered is their dotted name (e.g. 'foobar.interfaces.IFoobar').
That by itself is a string that might be presentable to users (but
really isn't).
So instead of falling back to the id, one could register the content
types with more useful names, e.g. IFile as 'File' and IFolder as
'Folder'. The current <interface /> ZCML directive doesn't do that yet,
it'd have to be extended or replaced with a custom one, maybe one that
already does the content type automation:
<foobar:contentType
interface="foobar.interfaces.IFooBar"
name="A foobar"
/>
Note that the 'name' parameter here should be a message id so that you
get to translate it right away. If you need to know what to do, look at
zope.app.component.metaconfigure.interface and
zope.app.component.interface.provideInterface...
Philipp
More information about the Zope3-users
mailing list