Default names

Skip to first unread message

Charlie Clark

Mar 18, 2016, 8:06:29 AM3/18/16

when creating and AddView based on FormView it seems it's essential to
have a `name` field. What's the best way to set this up if you don't want
these to be assigned by the user? Ideally, I'd like to have the context's
class name used as default and incremented but it seems like the validator
always expect a non-empty value.

Is the best way to use an AutoNamingFolder? If so, what's the best way to
hook this up as the default folder type?

Charlie Clark
Managing Director
Clark Consulting & Research
German Office
Kronenstr. 27a
D- 40217
Tel: +49-211-600-3657
Mobile: +49-178-782-6226

Carlos de la Guardia

Mar 19, 2016, 2:54:55 AM3/19/16

yes, the best way to not allow the user to assign names is to use an IAutoNamingFolder. It's very easy to hook one up as the default folder type. For the substanced scaffold, simply add this at the top of

    icon='glyphicon glyphicon-folder-close',
class MyFolder(SequentialAutoNamingFolder):
    """ Override Folder content type """

This will override the folder content type and use the SequentialAutoNamingFolder. To have the name begin with the content type, you would need to subclass this one.

To make this work with the document example in the scaffold, remove the name field from the DocumentSchema and change the add_success method in to:

    def add_success(self, appstruct):
        registry = self.request.registry
        document = registry.content.create('Document', **appstruct)
        return HTTPFound(
            self.request.sdiapi.mgmt_path(self.context, '@@contents')

That's all you need.

Carlos de la Guardia

From: Charlie Clark <>
Sent: Friday, March 18, 2016 6:06 AM
Subject: Default names
You received this message because you are subscribed to the Google Groups "substanced-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
For more options, visit

Charlie Clark

Mar 19, 2016, 8:52:05 AM3/19/16
Am .03.2016, 07:53 Uhr, schrieb 'Carlos de la Guardia' via
substanced-users <>:
Hi Carlos,

Google played merry hell with the formatting but I thought it would be
something like that. I see that a similar question came up recently so
I'll add this to the docs.

Jo G

Apr 13, 2016, 5:33:12 AM4/13/16
to substanced-users
I didn't use the autonaming folder  but I made the name property a hidden widget. I then updated the value in name field when I created the folder (in the add_success method) and where necessary if the properties were changed by overriding the set method of PropertySheet. I needed to do this as my name was a combination of the other fieldds. So for example, my person object name was a unique string which combines name,gender, birth and death.

 name = NameSchemaNode(
Reply all
Reply to author
0 new messages