Grok Community Documentation version 1.2

Customizing your MyDolmen site

Author:Vincent Fretin
Contributors:Aroldo Souza-Leite

You will customize your Dolmen application in the following parts of this tutorial.

Creating your own Dolmen site

In src/mydolmen/ module (remove all existing code), implement a Dolmen site by inheriting from the Dolmen class:

from import Dolmen

class MySite(Dolmen):
    title = u"My project site"

But MySite will have a default factory and so will appear in the Add menu. To disable the auto creation of the factory, change it like this:

from import Dolmen
from dolmen import content

class MySite(Dolmen):
    title = u"My project site"

For now, you only have the admin:admin account.

You can add a PAU to your application:

from import Dolmen
from dolmen import content
from import initialize_pau
from zope.authentication.interfaces import IAuthentication
from zope.pluggableauth import PluggableAuthentication as PAU
import grok

class MySite(Dolmen):
    title = u"My project site"
    grok.local_utility(PAU, IAuthentication, setup=initialize_pau, public=True, name_in_container="users")

And you need menhir.contenttype.user to create a user directory and create users.

Add to configure.zcml:

<include package="" />
<include package="menhir.contenttype.user" />

Add to


You have to recreate your application. You can now create a user directory (users) and create some users.

For the user, you can download the original image, with the namespace traverser download and the field name portrait:


Anywhere in the portal, you can access to an avatar, a square image:


It’s useful to develop a commenting system, like menhir.simple.comments.

Adding content types

We’ll add an Image content type.

Add to


Add to configure.zcml:

<include package="menhir.contenttype.image" />

Run the buildout. Restart the site. You can now add images.

Creating content types

Creating a folder and a content:

from dolmen.file import ImageField
from dolmen.blob import BlobProperty
from zope import schema
from zope.container.constraints import contains
from zope.interface import Interface

class IArtBook(Interface):

class ArtBook(content.Container):
    grok.implements(IArtBook)"My documents")

class IPicture(content.IBaseContent):
    description = schema.Text(title=u"Description")
    image = ImageField(title=u"Image")

class Picture(content.Content):
    content.schema(IPicture)'My document')
    image = BlobProperty(IPicture['image'])

We inherit from content.IBaseContent which contains the title. We define explicitly a BlobProperty for the image here. The content.schema directive will do the grok.implements too.

ArtBook container can contain only Picture objects. Picture can be added everywhere.

Add to configure.zcml:

<include package="dolmen.blob" />

and in your


For the image, you have access to thumbnails like this:

Changing the view of a content type

To change the view for a content type:

from import models

class PictureView(models.Index):

    def render(self):
        return "hello"

Include the type Image only in a IArtBook folder


from menhir.contenttype.image import IImage, Image
from zope.container.constraints import contains, containers
from zope.interface import Interface, classImplements

class IArtBook(content.IBaseContent):
    contains(".IPicture", IImage)

class IImageConstraints(Interface):

classImplements(Image, IImageConstraints)

Include slimbox preview for an image


from megrok.resource import component_includes
from menhir.contenttype.user import UserView
from menhir.contenttype.image import ImagePopup
component_includes(UserView, ImagePopup)

It is already done in the theme, but not in the theme.

Other functionalities

If buildout says that a package was not found, it’s probably the package doesn’t have a release yet. You normally add it to auto-checkout in sources.cfg to fix that.

There are some packages you can add to your buildout to add functionalities to your application. Simply add the package to and configure.zcml:


  • breadcrumbs
  • search box
  • add a view menu
  • menhir.simple.livesearch: add a livesearch to the searchbox
  • menhir.simple.navtree

Functionalities in development, may be buggy:

  • add cut, copy, paste functionalities
  • metadata tab on simple content type to edit dublin core metadata.

Content types:

  • menhir.contenttype.document
  • menhir.contenttype.file
  • menhir.contenttype.folder
  • menhir.contenttype.rstdocument
  • menhir.contenttype.image
  • menhir.contenttype.photoalbum

And other packages used in snappy demo:

  • menhir.simple.tag
  • snappy.*

You have the full list at