zopefoundation / Zope

Zope is an open-source web application server.
https://zope.readthedocs.io
Other
352 stars 99 forks source link

Logic Objects: Script (Python) Objects and External Methods #834

Closed bitxplora closed 4 years ago

bitxplora commented 4 years ago

I am new to Zope, so I am going through the Zope book, it was quite educative, until I got to the above subject, the whole of the chapter 7.4 https://zope.readthedocs.io/en/latest/zopebook/BasicObject.html#logic-objects-script-python-objects-and-external-methods. It talked about "select Script (Python) from the Add list", this option of "select Script (Python)" is not available in the Zope 4.4.2. It seems whole of chapter 7.4 is no longer obtainable, kindly review this. Thanks.

jugmac00 commented 4 years ago

Indeed. As noted at the top of the given page, you can read: "This document was written for Zope 2."

Afaik Script(Python) is now an addon, and comes no longer with Zope pre-installed.

You have to install https://github.com/zopefoundation/Products.PythonScripts separately.

This said, using PythonScripts is no longer the recommended way to develop for Zope.

I am a bit in a hurry now, but maybe you give us your reasons why you start with Zope? Have you inherited a legacy project or do you start from scratch?

I will check back later and give a more detailed answer.

bitxplora commented 4 years ago

Thanks for the prompt response, I got to know about Zope from trying to getting into Plone development, and since I did not want to limit myself to the "click and drag" of Plone, I thought I need to get conversant with Zope, in order to master Plone, so I am starting from scratch. It will be great, if I can have link to strictly zope 4 documentation. Thanks.

jugmac00 commented 4 years ago

So, I guess I have to disappoint you. There is no "strict" Zope 4 documentation.

Most of Zope's documentation lives here: https://www.zope.org/documentation/index.html#zope

Parts of it is updated for Zope 4, especially in the Zope Developer's Guide https://zope.readthedocs.io/en/latest/zdgbook/index.html

Zope does exist for about 20 years, and was extremely popular, and quite some documentation and books were written.

Nowadays, it is still alive and just recently was ported to Python 3, but the developer community is much smaller.

While it servers Plone as a very stable base, there are just too few people around to update all documentation.

It would be awesome, if you go through the documentation anyway, if you could either report problems or even better, create a pull request von GitHub with amended documentation. You can either click the "Edit on GitHub" link on the top right of the docs, or go straight to https://github.com/zopefoundation/Zope/tree/master/docs

If you plan to contribute, you should sign the contributor agreement https://www.zope.org/developer/becoming-a-committer.html

Plone has a much more up-to-date documentation, see here https://training.plone.org/5/mastering-plone/index.html

Generally, issues here at GitHub are used for feature requests and bug reports - so reports about unclear and outdated documentation are fine.

If you have beginners questions, usually the Plone forum is a great place: https://community.plone.org/c/zope/51

P.S.: I started my Zope journey by reading the documentation, and creating Pull Requests for it.

dataflake commented 4 years ago

In Zope 4 a lot of code that had been part of Zope 2 has been published as separate packages, including Products.PythonScripts (https://pypi.org/project/Products.PythonScripts/) and Products.ExternalMethod (https://pypi.org/project/Products.ExternalMethod/), which that chapter uses. If you include those in your installation you can continue following that chapter. How you do that depends on how you installed Zope. The installation documentation at https://zope.readthedocs.io/en/latest/INSTALL.html#custom-buildout-configurations provides some hints. If you used zc.buildout you can just add Products.PythonScripts and Products.ExternalMethod to the list of eggs, re-run the buildout and restart your Zope instance to pull them in.

Jürgen said that "using PythonScripts is no longer the recommended way to develop for Zope", but that's not a general truth. You shouldn't try to develop full applications with it, that's correct. But they are perfectly viable for other logic.

bitxplora commented 4 years ago

@jugmac00 and @dataflake thanks for your time and the help. I will like to be pointed to the resource for "the recommended way to develop for Zope". Thanks

jugmac00 commented 4 years ago

As already mentioned, the main source of documentation is https://zope.readthedocs.io/en/latest/

There, I'd recommend to read the Zope Developer's Guide - it does not hurt to start from the beginning, but if you want to directly jump into creating your own Zope based application, you can start with chapter 2 https://zope.readthedocs.io/en/latest/zdgbook/GettingStarted.html and have a look at chapter 5 https://zope.readthedocs.io/en/latest/zdgbook/Products.html

Unfortunately, chapter 5 has not been updated to Zope 4, yet. To give a broad hint... don't be shy to point out problems or even better, create a pull request with amendments.

While chapter 2 at least was updated to work with Zope 4, I cannot guarantee it follows the current best practices.

You could also have a look at one of the many Zope plugins/addons/products out there, and have a look at their source code: https://github.com/zopefoundation

When I had the same question as you, I was also pointed to have a look at Plone, as Plone is also a Zope based "application".

d-maurer commented 4 years ago

Jürgen Gmach wrote at 2020-5-18 23:27 -0700:

... When I had the same question as you, I was also pointed to have a look at Plone, as Plone is also a Zope based "application".

When Zope started (some decades ago), web applications on its base consisted mainly of Zope objects created and managed via the "Zome Management Interface" and (potentially) Zope extensions called "Product"s. As a result, a lot of logic and presentation logic was inside the ZODB (= "Zope Object Database"). That's fine for simple applications, but if you build large to huge applications, then you likely want support by a source control system (to monitor and coordinate source code changes). In those situations (requiring long term maintenance and the cooperation of many developers), you want your source code inside the file system (where it can be supported by the source code control system) and not inside the ZODB.

As a result, larger Zope applications have most of their logic and presentation code in the file system. "Pure" logic is typically directly implemented via Python packages/modules; presentation logic is typically split into a logic part (implemented by a Python class) and a presentation part (implemented by a template) and combined in a so called "View". Those applications are backed by the so called "Zope Component Architecture". Beside "View" it supports the concepts "utility", "adapter", "event" and "subscription". It is combined with a configuration language called "ZCML" (= "Zope Component Markup Language") to register components and bind things together. Use your favorite search engine to find detailed documentation about the "Zope component architecture".

bitxplora commented 4 years ago

Jürgen Gmach wrote at 2020-5-18 23:27 -0700: ... When I had the same question as you, I was also pointed to have a look at Plone, as Plone is also a Zope based "application". When Zope started (some decades ago), web applications on its base consisted mainly of Zope objects created and managed via the "Zome Management Interface" and (potentially) Zope extensions called "Product"s. As a result, a lot of logic and presentation logic was inside the ZODB (= "Zope Object Database"). That's fine for simple applications, but if you build large to huge applications, then you likely want support by a source control system (to monitor and coordinate source code changes). In those situations (requiring long term maintenance and the cooperation of many developers), you want your source code inside the file system (where it can be supported by the source code control system) and not inside the ZODB. As a result, larger Zope applications have most of their logic and presentation code in the file system. "Pure" logic is typically directly implemented via Python packages/modules; presentation logic is typically split into a logic part (implemented by a Python class) and a presentation part (implemented by a template) and combined in a so called "View". Those applications are backed by the so called "Zope Component Architecture". Beside "View" it supports the concepts "utility", "adapter", "event" and "subscription". It is combined with a configuration language called "ZCML" (= "Zope Component Markup Language") to register components and bind things together. Use your favorite search engine to find detailed documentation about the "Zope component architecture".

Thanks @d-maurer for these historical and technical illustration.