[Zope-CMF] Portal types q

Tres Seaver tseaver@palladion.com
Mon, 18 Jun 2001 09:55:13 -0400 (EDT)


On Mon, 18 Jun 2001, James van der Veen wrote:

>=20
> >At DC, we have adopted a pattern in which we create an ExternalMethod,
> >to be run against a newly-created CMFSite, which does all the initial
> >configuration for a custom site.  In your case, it might delete all the
> >type objects except NewsItem, e.g.::
>=20
> >   def just_news( self )
> >       """
> >           We only want to add NewsItems on this site.
> >       """
> >       types =3D self.portal_types.listContentTypes()
> >       types.remove( 'News Item' )
> >       self.portal_types.manage_delObjects( types )
>=20
>=20
>=20
>=20
> >or something like that (in this case, it could even be a Python
> >Script, using 'context' in place of 'self').
>=20
> >Tres.
>=20
>=20
> So before I do something stupid (Isn=B4t rare ;) )
>=20
> I should first create a CMF and then run this External Method?

Right.  Suppose you create a CMFSite object, 'JustNews', in the
root of your Zope.  You would then create the PythonScript,
perhaps called 'make_just_news', also in the Zope root.  Make
its body::

  types =3D context.portal_types.listContentTypes()
  types.remove( 'News Item' )
  context.portal_types.manage_delObjects( types )

You would then invoke it on your site via URL::

  http://your.site.tld/JustNews/make_just_news

Presto! Change-o!  your site can only add News Items.

Tres.
--=20
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
Tres Seaver                                tseaver@digicool.com
Digital Creations     "Zope Dealers"       http://www.zope.org