How can I override the "base_edit" view for a type using portal_factory?

It appears that when I use the portal_factory tool to instantiate the type, it ignores the view that I specified to override base_edit .

Here I have a setting:

  • An alias from edit to base_edit in the type tool.
  • View the class displaying the view.
  • ZCML, which binds the view class to the corresponding interface.
  • A content class that implements the corresponding interface.

I know that my overridden view of base_edit works because it displays:

  • Once an object has been created, it displays.
  • When I turn off the portal_factory tool for the type.

When I use a different name, such as custom_edit , it also displays an overridden view, even though the type is included in the portal_factory tool.

+4
source share
2 answers

Changing the alias to @@ base_edit also works. thus moving zope does an adapter search instead of accessing the attribute, and your editing will be used.

afaik @@ forces you to search for an adapter, without @@ the first object is called through receiving, and then the adapter

cc @juriejan

+3
source

You do not need to configure base_edit.cpt , you just need to create a new CMF skin template called yourtypenamenormalized_edit.pt , where "yourtypenamenormalized" is the name of your portal, whose name is lowercase and without spaces. The original Archetype base_edit.cpt will look for a template so named before applying all macros by default.

After that, I suggest you fill this new template with all the code that you find inside the default template, that is, edit_macro.pt , then start applying your changes.

Usually the only macro you want to override is the body macro.

+3
source

Source: https://habr.com/ru/post/1497226/


All Articles