[Zope] using formlib for nonclasic content types

Jim Pharis binbrain at gmail.com
Thu Jan 28 14:41:18 EST 2010


I went through the same motions as you in Zope2.12 trying to use Phillkon's
book as a guide. I think I ran into the same problem as you. The key is in
the package five.localsitemanager.

My Site Interface is nothing.

class IMySite(Interface):
    """My Site""

In my site.py I have the following.
...
from five.localsitemanager import make_objectmanager_site
...
class MySite(Folder):
    implements(IMySite)
    def __init__(self, id):
        setHooks()
        Folder.__init__(self, id='Mine')
        make_objectmanager_site(self) <----- key to making a OFS folder a
site
        setSite(self)
        notify(NewMySiteEvent(self)

After that you can treat your MySite OFS Folder like a site. Register
utilities with it, setHooks, and setSite.

Hope this helps,

- Jim


On Thu, Jan 28, 2010 at 2:40 AM, Roberto Allende <rover at menttes.com> wrote:

> Hello
>
> Following example 18.3.1 and 18.3.2 from phillkon's book, i'm trying to
> define a MySite class in Zope 2.12, which look like this:
>
>
>  class IMySite(IPossibleSite, IContainer):
>     """
>     """
>     id = ASCIILine( ...
>     name = TextLine( ...
>
>
>  class MySite(SiteManagerContainer, BTreeContainer):
>      implements(IMySite)
>
> So far so good, i've an interface and a class extending
> SiteManagerContainer and BTreeContainer. Problem becomes when i want to
> define the add form. If i'm not wrong, I cannot use the same machinery
> as zope3, so i was trying to use formlib:
>
>  class MySiteAddForm(AddForm):
>      form_fields=form.Fields(IListo)
>
> And i doesn't work. The error i'm getting is:
>
> NotImplementedError: concrete classes must implement create() or
> createAndAdd()
>
> I was looking info about them but i wonder i'm running with a conceptual
> gap here, because this is the same problem i had to define MySite
> inheriting from Folder. The same problem happened there, i was able to
> define the class but when i needed the form i wasn't able to use formlib
> and i used old-zope2-like-code. Probably i could try to do smt like
> that, but i'm very curious to see how can i use formlib in such cases.
>
> The question then is, is it possible or would it make sense to do
> something like this ?. Do you know about a sample code that could be
> helpful ?.
>
> Any comment or hint would be very appreciated.
>
> Kind Regards
> r.
>
> --
> http://robertoallende.com
>
> _______________________________________________
> Zope maillist  -  Zope at zope.org
> https://mail.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists -
>  https://mail.zope.org/mailman/listinfo/zope-announce
>  https://mail.zope.org/mailman/listinfo/zope-dev )
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.zope.org/pipermail/zope/attachments/20100128/4e3e3517/attachment.html 


More information about the Zope mailing list