Help with z3c.form and zope.file

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Help with z3c.form and zope.file

Danilo G B
Hey guys, please help me! I'm using Grok 1.4, z3c.form 2.4.2 and need a field to hold an uploaded file. I would like to have something as close as possible to plone.formwidget.namedfile. Whether I depend on z3c.namedfile, zope.app.file or zope.file the result is ultimately the same: complains about dependencies that goes down to the point where I can't go further, i.e,

    ConfigurationError: ('Invalid value for', 'menu', "ImportError: Couldn't import zmi_actions, No module named zmi_actions")

The (simplified) code is as follows:

from zope.interface import Interface
from zope import schema
import grok
from zope.schema.fieldproperty import FieldProperty
from megrok.z3cform.base import PageAddForm, Fields


class IDocMaster(Interface):
    title = schema.Text(title=u"The title")
    template = schema.Bytes(title=u"The template")

class DocMaster(grok.Model):
    grok.implements(IDocMaster)

    title = FieldProperty(IDocMaster["title"])
    template= FieldProperty(IDocMaster["template"])

    def __init__(self, title, template):
        self.title = title
        self.template = template

class DocAdd(PageAddForm):
    grok.context(Interface) #actually a specialised container
   
    fields = Fields(IDocMaster)
    label = "New doc"
   
    def createAndAdd(self, data):
        doc = DocMaster(**data)
        id = str(doc.title) #if you use a single word as title this will do
        self.context[id] = doc

In setup.py,

install_requires=[
          'setuptools',
          # -*- Extra requirements: -*-
          'zope.browserresource',
          'zope.app.pagetemplate',
          'z3c.form',
          'megrok.z3cform.base',
          'megrok.z3cform.ui',
          'megrok.z3cform.layout',
          'zope.app.schema',
          'zc.sourcefactory',
          'relatorio',
          #IF I INCLUDE THESE THE ABOVE MENTIONED ERROR OCCURS
          'zope.browsermenu',
          'zope.app.container',
          'zope.file',
          'zope.mimetype',
      ],

_______________________________________________
Grok-dev mailing list
[hidden email]
https://mail.zope.org/mailman/listinfo/grok-dev
Reply | Threaded
Open this post in threaded view
|

Re: Help with z3c.form and zope.file

Jan-Wijbrand Kolman-3
On 6/2/11 23:30 , Danilo G B wrote:

> Hey guys, please help me! I'm using Grok 1.4, z3c.form 2.4.2 and need a
> field to hold an uploaded file. I would like to have something as close
> as possible to plone.formwidget.namedfile. Whether I depend on
> z3c.namedfile, zope.app.file or zope.file the result is ultimately the
> same: complains about dependencies that goes down to the point where I
> can't go further, i.e,
>
>     ConfigurationError: ('Invalid value for', 'menu', "ImportError:
> Couldn't import zmi_actions, No module named zmi_actions")
>
> The (simplified) code is as follows:
>
> from zope.interface import Interface
> from zope import schema
> import grok
> from zope.schema.fieldproperty import FieldProperty
> from megrok.z3cform.base import PageAddForm, Fields
>
>
> class IDocMaster(Interface):
>     title = schema.Text(title=u"The title")
>     template = schema.Bytes(title=u"The template")
>
> class DocMaster(grok.Model):
>     grok.implements(IDocMaster)
>
>     title = FieldProperty(IDocMaster["title"])
>     template= FieldProperty(IDocMaster["template"])
>
>     def __init__(self, title, template):
>         self.title = title
>         self.template = template
>
> class DocAdd(PageAddForm):
>     grok.context(Interface) #actually a specialised container
>    
>     fields = Fields(IDocMaster)
>     label = "New doc"
>    
>     def createAndAdd(self, data):
>         doc = DocMaster(**data)
>         id = str(doc.title) #if you use a single word as title this will do
>         self.context[id] = doc
>
> In setup.py,
>
> install_requires=[
>           'setuptools',
>           # -*- Extra requirements: -*-
>           'zope.browserresource',
>           'zope.app.pagetemplate',
>           'z3c.form',
>           'megrok.z3cform.base',
>           'megrok.z3cform.ui ',
>           'megrok.z3cform.layout',
>           'zope.app.schema',
>           'zc.sourcefactory',
>           'relatorio',
>           #IF I INCLUDE THESE THE ABOVE MENTIONED ERROR OCCURS
>           'zope.browsermenu',
>           'zope.app.container',
>           'zope.file',
>           'zope.mimetype',
>       ],

Do you trigger the configuration for the last four dependencies from
your application? (by way of an include statement in your application's
configure.zcml?).

It seems the necessary menu components are not registered. But I'm not sure.

Are these extra dependencies for zope.file?

regards, jw


_______________________________________________
Grok-dev mailing list
[hidden email]
https://mail.zope.org/mailman/listinfo/grok-dev
Reply | Threaded
Open this post in threaded view
|

Re: Help with z3c.form and zope.file

Danilo G B
In reply to this post by Danilo G B
Yes, JW. I've included the packages' configure.zcml and meta.zcml but I don't know what to do to stop ConfigurationError: ('Invalid value for', 'menu', "ImportError: Couldn't import zmi_actions, No module named zmi_actions").

I know this is simple, since in the examples on http://grok.zope.org/documentation/how-to/uploading-file there is no mention of any other dependency but zope.file and zope.mimetype which makes me think older versions of Grok already included the required ones.

Thanx!


_______________________________________________
Grok-dev mailing list
[hidden email]
https://mail.zope.org/mailman/listinfo/grok-dev