On 2/9/12 10:12 AM, Andreas Jung wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
<browser:page> ZCML registrations require a class or an interface.
But how to I register a browser:page for a dexterity type that has
been defined through the web?
It seems to be possible to catch all Dexterity instance using
a registration for plone.dexterity.interfaces.IDexterityContent
however that's pretty unspecific.
What's the pattern here?
Lots of options...
1. There is actually an automatically generated interface you could use.
To use it you need to know its full dotted path, of course. It is in a
dynamic module (a la plone.alterego) called
plone.dexterity.schema.generated. You can look up the name of the schema
within that module this way:
from plone.dexterity.utils import portalTypeToSchemaName
schema_name = portalTypeToSchemaName(portal_type, u'', portal_id)
(Or look at the code in plone.dexterity.utils...it is a pretty simple
concatenation and encoding of those 3 arguments). I think it ends up
something like plone.dexterity.schema.generated.myportal_0_myportaltype_0_
2. Export your schema as supermodel XML (using the button in the
Dexterity types control panel). Put it in a file, and then load that
file into your custom interface that you name yourself, like this:
from plone.directives import form, Schema
class IMyContent(Schema):
model('path/to/model.xml')
Then register the browser view for IMyContent.
(The downside to this one is that you can no longer modify the schema
through the web.)
3. Write a behavior which adds a marker interface; then turn on that
behavior for your content type and register your view for the marker
interface.
4. Do it like in archetypes...create a view named mytype_view that's
technically available for all Dexterity content, but only list it as an
available layout in the FTI for your type. (Probably my least favorite
of the options.)
David
----------
David Glick
Web Developer
davidgl...@groundwire.org
206.286.1235x32
Engagement technology for social and environmental change.
http://www.groundwire.org
_______________________________________________
Product-Developers mailing list
product-develop...@lists.plone.org
https://lists.plone.org/mailman/listinfo/plone-product-developers