Understanding Zope's internal functions, from the eyes of Django

I am new to zope and I previously worked on Django for about 2.5 years. Therefore, when I first jumped on Zope (v2) (just because my new company has been using it since I was 7 years old), I came across these questions. Please help me understand them.

  • What is the “real” purpose of the architect as such? I know what he does, but tell me one great thing zodb does, and a framework like Django (which doesn't have zodb) skips.

    Update. Based on the answers, Zodb replaces the need for ORM. You can directly save the object inside db (zodb itself).

  • It is said that one of the functions of the zope killer is the concept of TTW (via the Internet or development using ZMI). But I (and any developer) prefer file-based development (using version control, using Eclipse, using any favorite tool outside of Zope). Then where is this TTW actually used?

  • This is big. That "EXTRA Stuff" increases Zope's gain when compared to Python / Django Inheritance.

  • Is this really a good step to come to Zope, from Django?

  • Any site like djangosnippets.org for Zope (v2)?

+7
python django zope zodb
source share
6 answers

First of all: current versions of zope2 include all zope3. And if you look at modern zope2 applications such as Plone, you will see that it uses a lot of "zope 3" (now called the "zope toolkit", ZTK) under the hood.

The real goal of ZODB: this is one of the few object databases (unlike relational SQL databases) that sees widespread use. You can "simply" store all your python objects there without the need for an object-relational map maker. No "select * from xyz" under the hood. And adding a new attribute to the zodb object "just" saves that change. Luxurious! It’s especially convenient when your data cannot be easily compared with a strict relational database. If you can easily match it: just use such a database, I used sqlalchemy several times in zope projects.

TTW: we are back from this. At least the zope2 TTW path really has all the flaws you fear. No version control, no external tools, etc. Plone is experimenting (google for "dexterity") with good explicit zope 3 ways to develop TTW that can still be displayed on the file system.

TTW: zodb allows you to easily and cheaply store all kinds of configuration settings in the database, so you can configure a lot in the browser. However, this does not mean typical TTW development.

Acquisition: A convenient trick, although it leads to huge use of the namespace. Double-edged sword. To improve debugging and maintenance, we try to do without most cases. The acquisition takes place inside the "object graph", so think about the folder structure inside the zope site. Calling contact_form with three folders down can find contact_form in the root of the site if it is not somewhere in between. Double-edged sword!

(And regular python-oriented object inheritance happens all over the place).

Moving from django to zope: a really good idea for certain problems and pointless for other problems :-) Quite a few zope2 / plone companies have actually done some django projects for specific projects, usually those that have 99% of their content in a relatively simple SQL database . If you are more versed in content management, zope (and plone) is probably better.

Extra tip: don't focus only on zope2. Zomp3 "component architecture" has many features for creating large applications (also not websites). Take a look at grok ( http://grok.zope.org ) for a friendly packaged zope, for example. The pure component architecture can also be used inside django projects.

+15
source share

On ZODB:

Another way to ask: "What is the real purpose of ZODB?" ask: "Why was the ZODB created?"

The answer to this question: the project was started very early, around 1996. This was before the existence of MySQL or PostgreSQL, when the miniSQL database (free, but not free software) was still used, or large monetary databases such as Oracle. Python has provided a brine module for serializing Python objects to disk, but lower-level serialization does not allow functions such as transactions, concurrent writes, and replication. This is what ZODB provides.

It is still used today at Zope because it works well. If you do not have an existing skill set in real-life databases, it’s easier to learn how to use ZODB than a relational database. It also allows you to use simpler use cases, for example, if you have a script command line that needs to store some configuration information, using a relational database means you need to start the database server to save a little configuration. You can use the configuration file, but ZODB also works very well, because it is an embedded database. This means that the database works in the same process as the rest of your Python code.

It is also worth noting that the API used to store objects inside containers differs between Zope 2 and Zope 3. In Zope 2, containers are stored as attributes:

root.mycontainer.myattr 

In Zope 3, they use the same interface as the standard Python dictionary type:

  root['mycontainer']myattr 

This is another reason it’s easier to learn ZODB than Django ORM, because Django has its own interface for ORM, which is different from existing Python interfaces.

Over the Internet (TTW):

Again, an understanding of the reason TTW dates back to when Zope was developed. Although it seems silly to break with well-known developer tools such as Subversion or Mercurial, Zope was developed in the late 90s when CVS was the only free version control system. Zope 2 had its simple version control features, and they were as good as CVS (that is, "they were limited and juicy"). Then UNIX workstations cost a lot more money and had much less resources, so system administrators were much more careful and cautious about server management. TTW allowed people who normally could not upload code to the server using sysadmin intervation, a way to do this.

With text editors, emacs and vi had ftp modes, and Zope 2 can listen on the FTP port. This will allow you to evolve so that the code is stored in ZODB (editable TTW), but it is customary to edit this code using emacs or vi.

Today in Zope, TTW is less commonly used or promoted since it no longer makes sense to do so. Disk space is cheap, servers are (relatively) cheap, and there are many tools for developers who expect to interact with a standard file system.

Acquisition:

It was a mistake. It was a very confusing feature that caused a lot of unexpected events. In theory, there are some interesting ideas for acquisitions, but in practice they are best thrown into the basket and are almost never used.

Migrating from Django to Zope:

Work began with Zope 3 in 2001. This fixed many problems with Zope 2. This is evidence from the Zope community that Zope 2 is still active and well supported, but it is unlikely to be up to date. Zope 2 is really interesting only from a historical point of view.

Zope 3 has evolved in several different directions, and therefore modern incarnations of Zope are best expressed as Grok, BFG or Bobo.

Grok is closest to Zope 3, and, as such, is a fairly large structure — it can be quite overwhelming from time to time when the code base sneaks through it. However, like Django or any other full-stack structure, you don’t need to use every part of Grok, it’s pretty easy to learn the basic ones and build web applications with it. This standard configuration is unmatched, and its cool views provide a much denser, possibly cleaner code base than the Django web application. This URL routing system is extremely flexible, but perhaps too redesigned.

BFG is a "pay for what you eat" written by longtime Zope developer Chris McDonough. Thus, it is closer to the Pylons in spirit, which includes only parts that are considered basic or essential to the frame. It also goes well with WSGI. It uses only a few basic Zope packages.

Bobo is a micro-frame. This is just a way to route URLs and serve the application. It does not use any Zope packages, therefore it does not belong to the Zope web frameworks family. But it was written by Zop's creator, Jim Fulton, who originally called the publishing part of Zop "Bobo." The original Bobo, written in the early 90s, matched the URLs with packages and modules, so if your source code was laid out as:

 mypackage.mymodule.MyClass 

You may have a url like:

 /mypackage/mymodule/MyClass 

It was very inflexible and was replaced by the Traversel URL in Zope 2, which is pretty tricky. Bobo uses Routes, so he is an intermediate between dead simple URL resolution and complex URL resolution - about the same complexity as Django's URL resolution mechanism.

+9
source share

I answer without much experience on both, but I had the opportunity to manipulate them, so I can tell you my opinion on some of your questions.

1) What is the “real” purpose of the architect as such? Meaning I know what he does, but tell me one wonderful thing that a zodb and wireframe like django (which does not have zodb) misses

Download distribution via ZEO and search through ZCatalog. From this point of view, Django is very low. To achieve this, you will have to redo many triangular wheels. Something I learned pretty soon: don't confuse problems with a low-level database. You ruin them. It can be a worm, the size of a dune .

So why choose django ORM? You should also consider if YAGNI . django is easy and self-sufficient, the documentation is premium, and when (if) your site grows so much, you will switch to a better ORM (or to pure OODB, in the case of ZODB) later.

2) It is said that one of the killers of the zope Feature is TTW (via the Internet or Development using ZMI). But I (and any developer) prefer File System Based Development (using Version Control, using Eclipse, using any favorite tool outside of Zope). then where is this TTW used?

I cannot answer this question correctly, but I would not say that it is fundamentally bad for development with such an approach. Of course, this is a change in thinking, and I also prefer file system development.

4) Is this a good move for work? Zope, from Django?

Zope 3 is very modular, so you can use many of its components from django. However, I would advise doing this. Of course you can, but what I found most problematic is the lack of help. Not many people use the zope and django components at the same time. Sooner or later you will have a problem and google will not help. At this point, you will realize that if your life was a video game, you definitely play it at a difficult level (maybe extreme if you have to put your nose into zope code).

+6
source share

A very good reference to the ZODB ZODB / ZEO Programmer's Guide . ZODB is not an ORM. Its a true database of objects. Python objects are stored transparently inside the database without worrying about how to convert them to a view suitable for the database. Any readable Python object can be stored inside ZODB. Relational databases are suitable for a large number of flat data (for example, employee records), while ZODB is best suited for hierarchical data (usually in web applications). I personally use Zope 3 for my applications. I have never done a TTW job. The best part of using ZODB was the fact that I never had to worry about how I was going to save data and how the situation would change when I upgrade my software from one version to another. For example, if I add a new attribute to a Python class, all I have to do is provide a default value as an attribute of the class. Then it becomes automatically available for all objects created with a previous version of the same class. Removing an attribute is a simple del operation on existing objects. BTW, ZODB can be used independently in any Python application and is not compatible with the ZOPE platform. I like the fact that I don't have to worry about nitty gritties SQL while working on Python thanx applications with ZODB. And, of course, if you need a database server so that you can run multiple copies of your application supported by the same server, ZEO comes to your aid on top of ZODB.

Zope began with the idea of ​​being an object publishing environment. From this point of view, mapping the URL directly to the object hierarchy in ZODB was great. URLs simply reflect the hierarchy of objects. Now, since finding out the URL is considered, the Rotterdam debugging interface is always needed. For development, I save the development flags in the zope configuration and view the contents of the ZODB through the Rotterdam interface. The Rotterdam shell provides a great way to introspect Python objects stored inside ZODB, and finding out URLs is much more interactive. In addition, for the main containers inside my ZODB, I register them as permanent utilities inside the site manager (Zope 3 sites and site managers). Anywhere in my code, when I need access to such containers, all I do is getUtility (IMyContainerType). I don’t even need to remember the detailed locations of these containers inside the code base. They are registered by the site manager and sent anywhere inside the code base via getUtility () calls. And URLs also support namespaces. For example, using the ++ ++ ++ namespace, you can change the skin of your web application at any time. Using the ++ ++ ++ namespace, you can change your preferred user interface language at any time. Using the namespace ++ ++ namespace, you can access the individual attributes of an object. URLs are simply much more powerful and much more customizable. And you can write adapter adapters, define your own namespaces to enhance the capabilities of your URLs. To give an example, all pages that are directly accessible from the web interface are part of my default skin. Although all the pages that are called via AJAX background calls are under a different skin. Thus, it is possible to implement various methods of authentication mechanisms in different skins. In the main skin, when authentication fails, it is redirected to another login page. For AJAX pages, you can simply get an HTTP error. This can be done centrally. Zope 3 objects have interfaces, and one view can be defined for several interfaces. Wherever you have an object that supports this interface, all related views become automatically accessible, and all such URLs are automatically valid. If you think about it, then it is much more powerful than a single python or XML file, where the URLs are hard-coded. I don’t know much about DJango and J2EE, so I can’t say if they have equivalent capabilities.

+6
source share

ZODB is an OO-style database that does not need a schema definition. You can simply create (almost) all kinds of objects and save them.

TTW is sometimes annoying, but you can mount a tree of ZOPE objects using webdav. Then you can edit templates and scripts using your favorite editor.

ZOPE is especially effective for creating CMS-like systems, IMHO there it still has no equal - you will have to go through a lot to make it work equally well in Django.

And through TTW, in fact, non-developers, such as designers, have good chances for development, for example. templates and CSS without the need for developer interaction.

+3
source share

+1 on Wheat's answer above: "Zope 2 is really only interesting to study from a historical point of view." I made Zope dev for a large site for several years, 50% zope 2, 50% zope 3. Even then (it was 2 years ago) we worked to migrate everything with zope 2. If you haven’t invested a lot in the existing one Zope 2 project, there is no reason to use it; there is simply not much future. And if you have a large existing zope 2 project, I would suggest taking a look at the product called Five (joke: 2 + 3 = 5), which aims to

allows you to integrate Zope 3 technologies into Zope 2. Among others, it allows you to use Zope 3 interfaces, ZCML-based configuration, adapters, browser pages (including skins, layers and resources), automatic forms for adding and editing based on the diagram, object events, as well as Zope 3-style i18n message directories.

When all is said and done, Zope 3 is a completely different structure from 2, and IMHO is much better (albeit more complicated). TTW is optional and not recommended for most cases. The implicit acquisition is gone.

It seems people here have explained why you might want to use ZODB, so I thought I mentioned one more thing about Zope 3 (or Zope 2 using Five), which is good. Zope has a very powerful system for connecting various application components called Zope Component Architecture (ZCA). It allows you to write components that are more or less autonomous and reusable, and which can be combined in a standard way. I mainly develop Django, and sometimes I miss the ZCA. In Django, the ability to write reusable components is limited and inactive. But, like Reinout, zope.component (like most zope packages, including ZODB) works outside the scope of zope and can be used in a Django project.

However, ZCA has its drawbacks, one of which is the tedious process of registering your components in XML files; I always had a bit of Java-esqe. One of the reasons I really like Grok http://grok.zope.org/ is because it sits on top of zope.component and does most of this work for you.

So bottom line: Zope 2 is basically a dead end. If your employer succumbs to this, start looking at Zope 3, or at least five. I think you will find that Zope 3 has a steep learning curve compared to Django, so it would be nice to come up with this through Grok, which smooths a lot of Zope 3 coarser edges. But I think that for a really big or complex web application with lots of moving parts, I would go for Zope over Django (and I say this as the person who really loves Django). For small projects, Django will probably be faster. The quantification of "large" and "small" in this context is difficult, and probably a few thousand more words will be required. If you're really interested in Zope 3, the book by Philipp von Weitershausen is definitely the place to start.

+1
source share

All Articles