Re: [Zope] How to make good architecture in Zope2?

2005-12-21 Thread Roman Suzi

Lennart Regebro wrote:


On 12/20/05, Roman Suzi [EMAIL PROTECTED] wrote:
 


Lets suppose that I've done OO Analysis and have a dozen of nice classes
which model my problem domain. Lets also suppose that I did it on the
basis of known use cases. Now I want to build Web application fulfilling
those use cases but  separate my  classes from Zope framework (Ok,  some
of them could be taken from Zope framework, like user folder), so that I
can see the problem domain abstractions in the clear, without a mess of
miriads of Presentation injections.
(I'd liked to put presentation-related things into other classes and ZPTs)

Are there any good examples out there, or any good architectural
solutions for that?
   



Yes. Zope 3. ;)
Zope 3 adresses several of these questions, especially the separation
of presentation from logic on a class bases. And of you can't use Zope
3, then you can use the same principals under Zope 2 thanks to the
Five technology:
http://codespeak.net/z3/five/

Five is included with Zope 2 since Zope 2.8.
 



Thank you for hints, Lennart. They are quite helpful. Its hard for me to 
competently say anything more on this as some time is required to

learn and try Five.

 


Or is it even possible in Zope2 to go that far
without doing to much adaptation?
   



No problems at all. Nuxeos new calendar product is done exactly like
that, even to the point that the base classes are in a separate
product (CalCore) that could be used outside of Zope, the UI is in
another product (CalZope) that provides all the pages, and we have
integration with CPS in a third product (a Plone integration,
CalPlone, is in progress).
 


This example is also interesting, thanks!


--
Lennart Regebro, Nuxeo http://www.nuxeo.com/
CPS Content Management http://www.cps-project.org/
 



___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


[Zope] How to make good architecture in Zope2?

2005-12-20 Thread Roman Suzi

Hi!

This question is not about how to make a Zope2 product, but how to get 
most from separating concerns while making Web application in Zope2.


Lets suppose that I've done OO Analysis and have a dozen of nice classes 
which model my problem domain. Lets also suppose that I did it on the 
basis of known use cases. Now I want to build Web application fulfilling 
those use cases but  separate my  classes from Zope framework (Ok,  some 
of them could be taken from Zope framework, like user folder), so that I 
can see the problem domain abstractions in the clear, without a mess of 
miriads of Presentation injections.

(I'd liked to put presentation-related things into other classes and ZPTs)

Are there any good examples out there, or any good architectural 
solutions for that? Or is it even possible in Zope2 to go that far 
without doing to much adaptation?


What I see in real world examples, is extensive use of mix-ins. Is it 
the only feasible way to at least textually separate Logic from 
Presentation?
(What about delegation?) Is there any pattern which doesn't look strange 
in Zope2 while letting me do what I described above?


Thank you in advance!

Regards,
Roman Suzi

___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


[Zope] Hooks for methods other than GET/POST on port 80?

2005-12-03 Thread Roman Suzi


Hi!

I am looking for a way in Zope to receive HTTP-requests with, eg,
DELETE and PUT in the object method. Zope (2.7.x) seems to intercept these and
issue Not authorised.

(I check REQUEST.REQUEST_METHOD to decide what to do in the object's method.
POST and GET are fine, but others are blocked in Zope.)

I do not want to do it the right way and create special kind of
ZServer (like for WebDAV), I just want Zope to let me decide what to do
if certain method is requested from a certain method of an object.

An example.
I want object X to receive a message Y with request method DELETE.
This is the raw thing the server need to receive:

DELETE /path/to/object/X/Y HTTP/1.1
Host: myhost.myorg.org
Content-Type: application/myprotocol+xml

Of course, I have a product Z which has this class:

class Z:
   ...

   def Y(self, REQUEST):
   if REQUEST.REQUEST_METHOD == 'POST':
# no problem
   elif REQUEST.REQUEST_METHOD == 'DELETE':
# this is never reached... Zope doesnt call Y


What do I tweak so object X will receive Y on a usual HTTP port 80?
THANKS!

Sincerely yours, Roman Suzi
--
[EMAIL PROTECTED] =\= My AI powered by GNU/Linux RedHat 7.3

___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Serve large files efficiently from a pipe

2005-11-09 Thread Roman Suzi

On Wed, 9 Nov 2005, Tino Wildenhain wrote:


Am Dienstag, den 08.11.2005, 22:34 +0200 schrieb Roman Suzi:

On Tue, 8 Nov 2005, Paul Winkler wrote:



  - I do not have named file... only file handler. But maybe named pipe
will do the trick... However, missing content-length (and unfortunately,
resulting content-length is not known) is the show-stopper.


What makes you think a file is always a named file? After all,
what you get from popen2 is just a file. The only hurdle you
need to take is the __len__ method on this object. So you
might need a little wrapper and/or investigate a bit what
ZPublisher does with it and how to prevent it (since you dont have
the size, do you?)


Ok... While it doesn't seem like right solution, anyway thanks!
That was my last option: to look how ZPublisher really do it.


Regards
Tino



Sincerely yours, Roman Suzi
--
[EMAIL PROTECTED] =\= My AI powered by GNU/Linux RedHat 7.3
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


[Zope] Serve large files efficiently from a pipe

2005-11-08 Thread Roman Suzi


Hi!

Newer Zope versions have an interesting ability to serve large files
efficiently given the file name ( 
http://plope.com/Members/chrism/ploneconf2004/2004pres.txt ).


What about serving large files given file(-like) handler? It could be
very beneficial sometimes, especially with dynamically generated
content...

Does Zope has anything for this?

Thank you for any ideas on this topic!

Sincerely yours, Roman Suzi
--
[EMAIL PROTECTED] =\= My AI powered by GNU/Linux RedHat 7.3
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Serve large files efficiently from a pipe

2005-11-08 Thread Roman Suzi

On Tue, 8 Nov 2005, Tino Wildenhain wrote:


Roman Suzi schrieb:


Hi!

Newer Zope versions have an interesting ability to serve large files
efficiently given the file name ( 
http://plope.com/Members/chrism/ploneconf2004/2004pres.txt ).


What about serving large files given file(-like) handler? It could be
very beneficial sometimes, especially with dynamically generated
content...

Does Zope has anything for this?

Thank you for any ideas on this topic!


Have a look at:

http://www.dataflake.org/software/filecachemanager

it implements what you are asking for.


Thank you for the link, however, it seems that it is not what I am looking 
for. I do not want the file contents be read into Python program as a whole 
but piped to the HTTP client. This piece of FileCacheManager code

give me doubts that this is how it works:



cache_entry = FileCacheEntry(self, ob, fname, self._tempfile_path) 
cache_entry.write(data) 



I want something which works similar to Unix pipe but for HTTP client:


this_generates_output | process_output  http_client


I do not want to store it anywhere on the FS and/or ZODB! And I certainly do 
not want to read the resulting file as a Python string into RAM. So,

I cant understand how RAMCache or FILECacheManager is going to help me.

I don't know if writing to response one chunk at a time is proper 
solution? Will Zope store response body or sent it right away? I am not 
sure that it is the later...




HTH
Tino



Sincerely yours, Roman Suzi
--
[EMAIL PROTECTED] =\= My AI powered by GNU/Linux RedHat 7.3
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Serve large files efficiently from a pipe

2005-11-08 Thread Roman Suzi

On Tue, 8 Nov 2005, Paul Winkler wrote:


On 11/8/05, Roman Suzi [EMAIL PROTECTED] wrote:
 I don't know if writing to response one chunk at a time is proper

solution? Will Zope store response body or sent it right away? I am not
sure that it is the later...


The classic way to do streaming data in Zope is like so:

RESPONSE.setHeader('Content-length', N)
for chunk in some_iterable_yielding_data:
   RESPONSE.write(chunk)

... where N is the size in bytes of the data you are going to write.


OK... Then streaming from Unix pipe can't be done in Zope...


However, you can also publish any method that returns an
implementation of IStreamIterator as shown in
http://svn.zope.org/Zope/trunk/lib/python/ZPublisher/Iterators.py?view=markup

The advantage is that this has less overhead, as once your method has
returned, the Zope app and ZODB are no longer involved, and your
iterator and ZPublisher do all the work.
This can become quite significant when you are streaming large data,
more than a few hundred kB. However, your iterator *must* be able to
do its work without a ZODB connection.

You haven't said where the data you want to stream is going to come from,


Sorry if it was not clear: data comes from a pipe (that is, from another
application, called by popen2...


so I can't guess whether the IStreamIterator technique will work for you...


 - I do not have named file... only file handler. But maybe named pipe
will do the trick... However, missing content-length (and unfortunately,
resulting content-length is not known) is the show-stopper.


--
http://www.slinkp.com



Sincerely yours, Roman Suzi
--
[EMAIL PROTECTED] =\= My AI powered by GNU/Linux RedHat 7.3
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Serve large files efficiently from a pipe

2005-11-08 Thread Roman Suzi

On Tue, 8 Nov 2005, Dieter Maurer wrote:


Roman Suzi wrote at 2005-11-8 13:05 +0200:

...
What about serving large files given file(-like) handler? It could be
very beneficial sometimes, especially with dynamically generated
content...


You must observe the restrictions required by HTTP!


HTTP 1.1 requires that if a response contains a Content-Length
header, then it *MUST* correctly specify the size of the response
entity. If it does not contain a Content-Length, then
its end *MUST* be indicated by closing the connection.

Zope is a bit buggy in this respect. It always adds a
Content-Length header, if the application did not do so.
Of course, this automatically added header has (almost surely)
the wrong value for dynamically created content.

Currently, Zope does not support the no Content-Length; response end
by connection close possibility.


Thank you all for explanations! While I do not necessary agree that Zope
is buggy in this respect, it could still be good for the purpose of
serving large files to have some by side technology, which doesnt require
ZODB access. Otherwise there is a need for Apache or whatever.

Sincerely yours, Roman Suzi
--
[EMAIL PROTECTED] =\= My AI powered by GNU/Linux RedHat 7.3
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )