RE: [Zope] Q: How are interactive web apps done?
-----Original Message----- From: Robb Shecter [mailto:shecter@darmstadt.gmd.de] Sent: Friday, January 21, 2000 3:08 PM To: zope@zope.org Subject: [Zope] Q: How are interactive web apps done?
Hi,
I've done lots of servlet programming, and am finally checking Zope out. It looks -very- interesting. I'd like to use it but I'm still trying to figure out how I'd use Zope in all the ways I use servlets.
For example:
A typical servlet-based web app uses the servlet API to automatically generate a session object for each user. (The API maintains the session by either a cookie or url rewriting.)
Similar mechanisms are employed by current Zope Session Products.
A small inheritance framework can easily be written to make some servlets do authentication in their base classes before allowing the user to continue.
Zope begins to differ at this point, subtly. Although there is nothing stoping an inheritance relationship from participating in authentication, and in some situations it does, in Zope, authentication is primarily acomplished using Acquisition, which is a containment relationship, not an inheritance relationship; meaning that instances acquire authentication information (or mechanisms) from the environment around them, aka, all the other instances in the system. Inheritance ususaly takes a part in the definition of the genetic material of the various authentication components, like Users, and 'User Folders' (which are a bit poorly named, often they don't have any 'Folder' like interface).
The subclasses then can get the session object, which is a hash table of objects. One might then define a User java object that gets put into the session after authentication in the base class. Now all of the user's attributes can be accessed by the servlets.
What is the equivalent way of doing things in Zope? I've read about the various user permissions, but I'm not sure how that'd be used in a web application.
I suspect Zope provides a much higher level framework than you're used to. For example, Zope automaticly inserts the current User object into the web request. Zope authentication mechanisms takes care of authenticating the user and constructing the user object (of course, you can create your own kind of user objects with Python code). All you as a content manager need to are create Roles that define the various 'groups' of your users, map a collection of permissions to each Role. The actions a user are allowed to do are the union of all the permissions of all their Roles. You can get down and dirty, in Python. You can completely discard Zope's authentication and acquisition mechanisms and just use it's object publishing ORB and some database modules to simulate what Java Servlets give you. This is much lower level than sitting in the Zope managment interface.
For example, how would an interactive banking application be implemented in Zope? Where would you define what info you want to save about each user?
A relational database could be a good place if you used UserDB, which is a Zope authenticator which works against RDBMs. I'm assuming this would be the method you are acustomed to with Servlets.
How is the ODB used in a more database-like way, as opposed to a transparent web document source way? Or, is there no difference?
There is a difference, and that's when all the research we're doing right now starts to come into the discussion. Whereas we and others have come up with various hackish ways of working with dynamic user schemas and how users look in various system contexts, no generic, reusble mechanism has arisen because the problem is so hard, and I suspect many of the Java platforms punt on a generic reusable mechanism for the same reason. For example, lets say you had a whole Suite of applications. In this environment, you want to maintain an identy accross all applications, possible across multiple remote platforms. Each application may want each user object to look or act completely different. Some applications may consider the information they want to store about the user to be confidential, while other applicaitons may have a lower security barrier and authorization may be necessary for certain applications to allow other applications access to the information they are concerned about in the user. Is there a central LDAPish user repository? Both? Do individual applications keep localized user information? How do users synchronize possibly remote data? How does user managment propegate then to the distributed sources? Does the user or the application control the security between applications? What if two applications define two semantically identical bits of information but uses them in wildly different ways? What if you want to use legacy data (LDAP, RDBM). etc... We've been asking these questions for about a year now, and there's been alot of head scratchin'. What we're conceiving is a generic reusable mechanism which addresses at least a few of these questions. -Michel
Hi, Thanks for the reply. Over the weekend I read the Zope Content Manager's Guide, the Developer's Guide and the DTML reference. I'm still trying to get a handle on everything, though. Michel Pelletier wrote:
A typical servlet-based web app uses the servlet API to automatically generate a session object for each user. (The API maintains the session by either a cookie or url rewriting.)
Similar mechanisms are employed by current Zope Session Products.
Do you mean the FSSession and SQLSession products? I found them by searching at zope.org. They seem to be similar except where they store the session info. Is this right?
...Acquisition...
Yes, acquisition seems like a very nice mechanism that may be more appropriate than inheritance for lots of cases.
...I suspect Zope provides a much higher level framework than you're used
to.
Yes, absolutely. If possible, I'd like to use the high level features. It's still not so clear to me, though, how the parts fit together. In servlets, you've got your server (app-logic) objects that are long lived, and can be accessed by servlets. The servlet framework uses a Template Method pattern: A servlet has an init() methods that's called once, and then a get() or post() method that's called per invocation. This is nice for setting up db and server connections, etc. In Zope is this accomplished by Python classes that get used as external methods?
...You can get down and dirty, in Python. You can completely discard Zope's authentication and acquisition mechanisms and just use it's object publishing ORB and some database modules to simulate what Java Servlets give you.
But I'd like to use the high-level features if I can. I'm wondering, for example, what the architecture would be for a site like "my.yahoo.com", or "zope.org", where a user can create an account through the web, and have it verified by email. Then, when "logged in", the site can react in a stateful way to the user's actions.
A relational database could be a good place if you used UserDB, which is a Zope authenticator which works against RDBMs. I'm assuming this would be the method you are acustomed to with Servlets.
I actually just defined my own User classes, and persist them in XML or serialized files. I was about to look for a real rdbms, and decided to check out moving to Zope, since it has one combined with it. - Robb
participants (2)
-
Michel Pelletier -
Robb Shecter