Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Zope: CMF

Formlib for folders

 

 

Zope cmf RSS feed   Index | Next | Previous | View Threaded


charlie at begeistert

Feb 13, 2008, 4:01 AM

Post #1 of 4 (296 views)
Permalink
Formlib for folders

Hi,

as my current project uses objects derived from PortalFolder and I'm
trying to use browser views, it looks like I might be able to provide
a formlib based version of browser/folder.py

Is anyone already working on this? As usual I have more questions than
answers: the first:

do we need a vocabulary for the content_types? ie. something like

ContentTypeVocabularyFactory = StaticVocabulary(allowed_content_types)
or would this be too restrictive? As it stands I'm not terribly sure
how to get the allowed_content_types without a context

Charlie
--
Charlie Clark
Helmholtzstr. 20
Düsseldorf
D- 40215
Tel: +49-211-938-5360
GSM: +49-178-782-6226



_______________________________________________
Zope-CMF maillist - Zope-CMF[at]lists.zope.org
http://mail.zope.org/mailman/listinfo/zope-cmf

See http://collector.zope.org/CMF for bug reports and feature requests


wichert at wiggy

Feb 13, 2008, 4:16 AM

Post #2 of 4 (281 views)
Permalink
Re: Formlib for folders [In reply to]

Previously Charlie Clark wrote:
> do we need a vocabulary for the content_types? ie. something like
>
> ContentTypeVocabularyFactory = StaticVocabulary(allowed_content_types)
> or would this be too restrictive? As it stands I'm not terribly sure
> how to get the allowed_content_types without a context

vocabulary factories take a context as argument.

This vocabulary is already implemented in plone.app.vocabularies, you
can just use that:
http://dev.plone.org/plone/browser/plone.app.vocabularies/trunk/plone/app/vocabularies/types.py

Wichert.

--
Wichert Akkerman <wichert[at]wiggy.net> It is simple to make things.
http://www.wiggy.net/ It is hard to make things simple.
_______________________________________________
Zope-CMF maillist - Zope-CMF[at]lists.zope.org
http://mail.zope.org/mailman/listinfo/zope-cmf

See http://collector.zope.org/CMF for bug reports and feature requests


charlie at begeistert

Feb 13, 2008, 2:14 PM

Post #3 of 4 (279 views)
Permalink
Re: Formlib for folders [In reply to]

Am 13.02.2008 um 13:16 schrieb Wichert Akkerman:

> vocabulary factories take a context as argument.
>
> This vocabulary is already implemented in plone.app.vocabularies, you
> can just use that:
> http://dev.plone.org/plone/browser/plone.app.vocabularies/trunk/plone/app/vocabularies/types.py


Thanks very much for this. Would it be possible to include the two
portal_types vocabularies in CMFDefault?

I got the vocabulary in my view class but then I got an Assertion
Error relating to it:

2008-02-13 21:16:34 ERROR Zope.SiteErrorLog http://localhost:8080/new/b/@@edit.html
Traceback (innermost last):
Module ZPublisher.Publish, line 119, in publish
Module ZPublisher.mapply, line 88, in mapply
Module ZPublisher.Publish, line 42, in call_object
Module zope.formlib.form, line 769, in __call__
Module Products.Five.formlib.formbase, line 55, in update
Module zope.formlib.form, line 732, in update
Module Products.camaoCms.browser.masterpage, line 86, in setUpWidgets
Module Products.CMFDefault.formlib.form, line 117, in setUpWidgets
Module zope.formlib.form, line 379, in setUpEditWidgets
Module zope.schema._field, line 244, in bind
AssertionError

Looking at the source:

def bind(self, object):
"""See zope.schema._bootstrapinterfaces.IField."""
clone = super(Choice, self).bind(object)
# get registered vocabulary if needed:
if IContextSourceBinder.providedBy(self.vocabulary):
clone.vocabulary = self.vocabulary(object)
assert ISource.providedBy(clone.vocabulary)
elif clone.vocabulary is None and self.vocabularyName is not
None:
vr = getVocabularyRegistry()
clone.vocabulary = vr.get(object, self.vocabularyName)
assert ISource.providedBy(clone.vocabulary)

looks like I'm a victiom of copy & paste programming (again! ;-) The
vocabulary definitely doesn't provide ISource but I can't seem to get
this to work: either by adding it as a parameter to implements() or in
ZCML leads to a lookup error:

ComponentLookupError: (<InterfaceClass
zope.schema.interfaces.IVocabularyFactory>,
'cmf.UserFriendlyContentTypes')

mm, guess I need to double check my declarations. I thought that

implements(IMyInterface)

is equivalent to provides="...IMyInterface" in ZCML

BTW. this is probably academic but I noticed the top of the types.py is
from zope.app.schema.vocabulary import IVocabularyFactory
Is there a reason for not importing the interface directly?

I'll also be reading up ISource in Philip's book.

Charlie
--
Charlie Clark
Helmholtzstr. 20
Düsseldorf
D- 40215
Tel: +49-211-938-5360
GSM: +49-178-782-6226



_______________________________________________
Zope-CMF maillist - Zope-CMF[at]lists.zope.org
http://mail.zope.org/mailman/listinfo/zope-cmf

See http://collector.zope.org/CMF for bug reports and feature requests


charlie at begeistert

Mar 11, 2008, 9:21 AM

Post #4 of 4 (207 views)
Permalink
Re: Formlib for folders [In reply to]

Am 13.02.2008 um 23:14 schrieb Charlie Clark:

> BTW. this is probably academic but I noticed the top of the types.py
> is
> from zope.app.schema.vocabulary import IVocabularyFactory
> Is there a reason for not importing the interface directly?


I've finally got some initial code for this.

def contentTypeVocabulary(context):
type_infos = context.allowedContentTypes()
types = [SimpleTerm(t.id, t.id, t.Title()) for t in type_infos]
return SimpleVocabulary(types)

ContentTypeVocabularyFactory = Factory(ContentTypes)

Unless I'm very much mistaken the action for adding an item to a
folder can be achieved by something like the following:

def _handle_success(self, action, data):
id = data['id']
type_name = data['content_types']
self.context.invokeFactory(type_name, id)

Although I'm not quite sure on handling the redirection to the newly
created object.

Charlie
--
Charlie Clark
Helmholtzstr. 20
Düsseldorf
D- 40215
Tel: +49-211-938-5360
GSM: +49-178-782-6226



_______________________________________________
Zope-CMF maillist - Zope-CMF[at]lists.zope.org
http://mail.zope.org/mailman/listinfo/zope-cmf

See http://collector.zope.org/CMF for bug reports and feature requests

Zope cmf RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.