[Zope3-Users] Re: Can I open data.fs file in R/W with ZODB in two programs (two process, no thread) at the same time ?

2006-12-06 Thread Philipp von Weitershausen

KLEIN Stéphane wrote:

Can I open data.fs file in R/W with ZODB in two programs (two
process, no thread) at the same time ? If not, is there other ZODB
storage system
to do that ?


Start a ZEO server that accesses Data.fs via standard FileStorage. Then 
from each program or Zope instance, connect to the ZEO server via 
ClientStorage. My new book explains how to set this up: 
http://worldcookery.com.


--
http://worldcookery.com -- Professional Zope documentation and training
2nd edition of Web Component Development with Zope 3 is now shipping!

___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] schema field for an Image?

2006-12-06 Thread Adam Summers

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


Re: [Zope3-Users] schema field for an Image?

2006-12-06 Thread Tahara Yusei
Hi,

 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).

In such case, I use custom widget.


from zope.app.form.browser.textwidgets import FileWidget
from zope.app.file.image import Image
class MyImageWidget(FileWidget):
  class_ = Image
  def _toFieldValue(self, input):
value = super(_toFieldValue, self)._toFieldValue(input)
return self.class_(value)

from zope.formlib import form
class MyEditForm(form.PageEditForm):
  form_fields = form.FormFields(IMyContent)
  form_fields['image'].custom_widget = MyImageWidget


And there is widget subdirective in addform/editform directives in zcml.

-- 
Tahara Yusei
[EMAIL PROTECTED]
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users