Hi,
Tom Dossis wrote:
Sascha Ottolski wrote:
I'm wondering if anything already exists, that would allow me to define
a schema like (pseudo)
IPerson(Interface):
image = File(
max_size=100,
)
Person(Persistent):
implements(IPerson)
image = FileProperty(form_fields['image'])
with the result, that the image attribute behaves pretty much like an
IImage, that is, has contentType and size associated with it, and might
be easily displayed with the help of something like
zope.app.file.browser.image.ImageData.
I already tried to create such a Property, as well as using
schema.Object, but wasn't really successfull :-(
Hi Sacha, I've used something like this...
class IPerson(Interface):
image=schema.Object(
schema=zope.app.file.interfaces.IImage,
required=False, # You may need this depending on validation needs..
)
class Person(Persistent):
implements(IPerson)
image=FieldProperty(IPerson['image'])
If I wanted to use formlib to build the form, and wanted to build a HTML
widget for the image field that had a
file input for uploading, and if img already had content woudl display a
thumbnail; how would I go about this? I'm afraid I'm lost because its
schema.Object that the widget would apply to (but I'm not sure).
regards,
Adam
If you want to make the image attribute traversable (via the url) the
z3c.traverser package can do the job.
Of course, I can do all this by hand for each content object by adding
a contentType attribute and providing some views, but I have the
feeling that there would exist a smarter way to to this.
Adding to this, is there a way to register views with fuzzy names?
Think of a class
Person:
resume = File()
Now, to help the logfile analyzer, I would like to have a view
named resume.%s', so that if resume is a Word document, it could be
accesed as /person1/resume.doc, if resume is PDF, access would
be /person1/resume.pdf. I could register several views for common
suffixes, but than there comes a buy with one no one thought of. May be
this is a stupid idea anyway :-)
Have a look at zope.publisher.interfaces.IPublishTraverse to hook in
your own handler for traversing a Person object.
regards,
-Tom
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users