tmaster
tmaster

Reputation: 9655

How to set BaseBTreeFolder object's name?

I created this object which inherits from plone.app.folder.base.BaseBTreeFolder. After creating it, Plone sets a long name which contains the object name and creation date to it. How can I change the name to the same as title?

Upvotes: 1

Views: 40

Answers (1)

Martijn Pieters
Martijn Pieters

Reputation: 1123850

You need to register your type with the factory tool.

When so registered content is created initially inside a sandbox, just so you can fill out the edit form for the first time. Once you submit the edit form, the item is created for real and is given an id based on the title.

To register, either manually enable your type on the "Factory Types" tab of the portal_factory object (in the ZMI), or register your type in your GenericSetup profile with a file named factorytool.xml containing:

<?xml version="1.0"?>
<object name="portal_factory">
 <factorytypes>
  <type portal_type="YourTypeName" />
 <factorytypes>
</object>

You also need to make sure your type has the rename flag set to True; in your class definition add:

_at_rename_after_creation = True 

Upvotes: 2

Related Questions