Zope.org - Authoring Content with WebDAV and FTP

来源:百度文库 编辑:神马文学网 时间:2024/04/27 19:24:24
Authoring Content with WebDAV and FTP
Isn‘t the Web fun? Any knucklehead with Dreamweaver, Emacs, or a host of other tools can quickly whip up their brilliant words, move their content over to the server using basic protocols, and be recognized for their genius and contribution to humanity. However, Web publishing has increasingly become unmanageable. Sites need policies, organization, navigation, and a host of other services that a simple filesystem can‘t support. Unfortunately, this usually means relational databases, which are notoriously at odds with the hierarchical data model of both the Web and authoring tools.

By Jeffrey Shell
 
Overview of Remote Authoring
Isn‘t the Web fun? Any knucklehead with Dreamweaver, Emacs, or a host of other tools can quickly whip up their brilliant words, move their content over to the server using basic protocols, and be recognized for their genius and contribution to humanity.
However, Web publishing has increasingly become unmanageable. Sites need policies, organization, navigation, and a host of other services that a simple filesystem can‘t support. Unfortunately, this usually means relational databases, which are notoriously at odds with the hierarchical data model of both the Web and authoring tools.
Zope is an Open Source application server for building content management systems. And Zope uniquely solves this problem, thanks to its tree-structured object database. With Zope, authors can use familiar tools and familiar protocols to directly work on remote content objects.
This article covers the basics for authoring Zope content from three popular applications: BBEdit, GoLive, and Cadaver.
Getting Started
This article presumes that you have login access to a Zope site that uses the Content Management Framework (CMF). The CMF extends Zope to provide important content management services such as membership, personalization, cataloging, and workflow.
The Zope site that you are using must be accessible by both FTP and WebDAV, two protocols for moving "files" across the Internet. In Zope, this means that the Zope server must be listening on a port for FTP and a "source port" for WebDAV.
Alternatively you can simply get an account on Zope.org and follow these examples using our sample Zope.org account, so you do not even need to install Zope to try this. (Note: at the time of this writing Zope.org is transitioning to use the CMF.)
Authoring With FTP
The Zope application server can speak a number of protocols, including FTP. This means that you can open an FTP session and connect to a Zope server just as if it were a regular FTP site. Zope folders (or any object that acts like a folder) gets mapped to a directory, and Zope folder items look like files. But inside, there‘s a powerful and dynamic application server that doesn‘t use directories and files at all.
Let‘s presume you have a membership on Zope.org with a login name of bruce and a password of stillbruce. Zope.org allows FTP connections to the hostname ftp.zope.org on port 21. Thus, a simple, command-line unix FTP session would look as follows::
$ ftp ftp.zope.org 21 Connected to ftp.zope.org Name: bruce 331 Password required. Password: 230 Login successful. Remote system type is UNIX. Using binary mode to transfer files. ftp> cd /Members/bruce 250 CWD command successful. ftp> ls 200 PORT command successful. 150 Opening ASCII mode data connection for file list d--------- 1 Zope Zope 0 Jun 19 20:57 .. -rw-rw-r-- 1 Amos Zope 13117 Jun 6 2000 Example.tgz -rw-rw---- 1 Amos Zope 385 Sep 15 1999 index.html 226 Transfer complete
In this example, we connect to Zope, change directories to our member folder, and list the objects in the folder. Some command line FTP tools even let you get and put whole directories and files.
Using FTP with BBEdit
Many authors, though, use desktop tools that directly work with FTP. On the Mac OS, editors such as Alpha,BBEdit, and Pepper all support direct manipulation of remote content. And of course, the larger HTML tools such as GoLive and Dreamweaver support both WebDAV and FTP. This section takes a look at authoring a new piece of content in BBEdit using its FTP mode.
First, we have to make some content. Create a new document using File->New and enter the following HTML::
Hello world, I am Bruce.
 
Now we need to save it to a Zope site. BBEdit has the command Save to FTP Server..., located under the File menu, with the keyboard shortcut shift-command-s. Selecting this option brings up a dialog box similar to the old open/save dialogs with some extra options.

Figure 1. BBEdit Save Dialog.
 
An important thing to note is that many Zope server installations don‘t run FTP on the normal port 21. You need to make sure that your editor supports being able to save FTP on other ports. Most of them do, although in ways that aren‘t always obvious. For BBEdit and Pepper, you supply the port name after the host name, separated by a colon. So, to save this document at ftp.zope.org, which publishes FTP on port 8021, enter in ftp.zope.org:8021 in the "Server" text field. Enter bruce and stillbruce in the name and password fields. And make sure the "Passive FTP" box is checked. But don‘t hit Connect just yet! You need to tell BBEdit where your member folder is.

Figure 2. BBEdit Go To Folder.
 
On the left side of the dialog box, click the Go To... button. A smaller dialog will pop up letting you set the path to go to after login. Enter in /Members/bruce and click Go to close the dialog box. Now click Connect. You‘ll see a directory listing of any items (if any) in your member folder. Enter the name hello.html in the text field below the item listing, and then click save.
Saving the file means that BBEdit, using its Save to FTP abilities, created a new "file" in the /Members/bruce "directory". In Zope parlance, a new document object was created in your member folder.
Well, so what? Big deal, FTP servers have been doing this for decades. To get a glimpse of why this is interesting, open a Web browser and log in to your member area. Go to the URL of the document you just created. In the above example, the URL would be http://www.zope.org/Members/bruce/hello.html. You will see a page such as the following::

Figure 3. Your hello.html file served from Zope.
 
Wait a minute, where did all that extra HTML come from? This is where the power of Zope begins to appear. The title and body of your HTML file where extracted and viewed through a site template. The above screenshot illustrates one possible view of your document. Zope can dynamically tailor your document‘s presentation in response to many conditions such as the viewer‘s preferences, business rules, security constraints, etc.
You can edit your new "file" through the Web (if logged in, click on Edit). Your file is immediately searchable (but only by you if the page hasn‘t been approved by a reviewer). You can also undo previous changes and view the history of a document.
"OK, you‘re right, it‘s more than a FTP server. How does it do it?" Zope is a powerful application server and content management system. Zope stores your content in its own database and provides your content with many services such as security, searching, dynamic presentation, clustering, workflow, and more. By storing your content in Zope you can use Zope‘s rich services to give your content dynamic capabilities. Later in this article you‘ll find out more about some of Zope‘s many services.
Final Thoughts On FTP
Though not all of the commands of FTP are implemented, most of the important operations are available. This includes delete, rename, and creating a directory.
While FTP is extremely ubiquitous, it has a number of glaring problems. For instance, FTP does not have strong security and isn‘t firewall friendly. At a deeper level, FTP has a simplistic view of content, with no concept of "content type". This often leaves the client or server with nothing but the name of the item and the FTP command given to know what to create.
Fortunately the Web has a replacement ready for FTP. The WebDAV protocol (http://www.webdav.org) is a series of extensions to HTTP to support distributed authoring. Zope supports WebDAV in a fashion similar to FTP. In the next section we‘ll look at authoring Zope content through WebDAV tools.
Authoring With WebDAV
In the past year, support for WebDAV has greatly increased. Authors can now use WebDAV from tools such as Dreamweaver and Adobe products such as Photoshop and GoLive. In fact, WebDAV is being supported in the operating system and desktop environment for Windows (Web Folders) Mac OS X (mount), and Gnome (GnomeVFS and Nautilus).
However, WebDAV suffers from a problem that FTP, in practice, doesn‘t face. This problem is known as "source vs. rendered".
Many websites these days have URLs that produced dynamically rendered HTML pages. There are many template technologies that do this: ASP, JSP, PHP, etc. Zope also works this way.
When you retrieve a page on a website, you are getting the rendered version. This might include all kinds of HTML that isn‘t in the actual content, but which comes from the site templates. If you want to edit your page, you need the "source" version, not the "rendered" version.
The good news is that the WebDAV specification anticipates this. The bad news is that, simply stated, none of the WebDAV clients support it. Clients have yet to implement an "Edit Source" option that fetches the source version of a document.
Zope works around this problem listening on a second HTTP port for serving source documents. Thus, you could browse http://www.zope.org/ and see all the rendered pages, but tell your WebDAV client to go to http://www.zope.org:9800/ to retrieve the source versions. Kind of kludgy, but it works.
With this lesson in WebDAV mechanics behind us, let‘s take a look at using WebDAV on Windows, Linux, and Mac OS.
Using WebDAV with Web Folders
Microsoft is the original champion of WebDAV. Through "Web Folders", they have supported WebDAV for years. In many cases, though, Web Folders are an option that must be added from the Windows CD.
Web Folders are what they sound like. They make a remote collection look like a folder hierarchy in Windows Explorer. You can browse a remote folder‘s contents, drag and drop content back and forth from the remote site to your local drive, and perform limited in-place operations like inspecting file properties.
It‘s what you can‘t do that is so frustrating. You can‘t edit in place, unless you use Microsoft‘s Office products. Other applications don‘t use the plumbing. You can‘t treat a remote "directory" as if it was a local drive. (Commercial productsWebDrive andTeamDrive , however, do this). Moreover, Microsoft has released different versions of the WebDAV plumbing over the years.
Let‘s see how to make a Zope folder look like it is part of the Windows desktop. First you need to create a Web Folder. Doing this is slightly different for different versions of Windows or Office. In Windows 2000 you go to Explorer and click on My Network Places. The folder contains an icon for Add Network Place
Double-click on Add Network Place and fill in the dialog box with the URL to the WebDAV source port. For the Zope.org user folder used in this example, the URL is http://www.zope.org:8088/Members/bruce.

Figure 4. Add network place dialog box.
 
Click Next> and, on the next screen, Finish adds a new Web Folder appears under My Network Places. You can use it from this location or create a shortcut on the Windows desktop.
Now double-click on the Web Folder the represents your Zope.org member folder. You‘ll be prompted to login, something that Web Folders likes to do repeatedly. You now see all the items that you‘ve created.
From this point on you can author your content on your local drive, then drag-and-drop whole directories onto your Web Folder for updating.
Using WebDAV with Adobe GoLive
GoLive is a site design tool from Adobe in the spirit ofDreamweaver. The 5.0 version, released in 2000, allows remote publishing through FTP and WebDAV. With WebDAV you can also use workgroup features such as checkin, checkout, and locking. (Note: WebDAV locking is supported in Zope 2.4, which is currently in alpha testing).
In GoLive you can administer content and site design in two ways: in-place and synchronized. That is, you can directly browse a Zope folder and edit HTML or you can keep your HTML locally and use convenient interfaces to publish to the Zope site. This section talks about using GoLive‘s WebDAV Browser, which lets you edit and author new remote content directly.

Figure 5. Adobe GoLive 5 WebDAV Browser Connect.
 
To start with, we need to connect to the Zope server. This is done by choosing WebDAV Browser from the File menu. In the address field enter http://www.zope.org:8088/Members/bruce. In the Username and Password fields, enter bruce and stillbruce respectively. Set the authorization popup menu to Basic and click Connect. At this point, you‘ll get a listing of items in your member folder, which should look similar to this:

Figure 6. Adobe GoLive 5 WebDAV Browser Contents.
 
Now you can double click on the hello.html document you made earlier and GoLive will open it up for you. When you open the document, GoLive will raise a warning dialog about the document having no encoding information. Click on "OK". Now you can use all of GoLive‘s built in editing facilities to edit the document. Every time you save, the changes are written to the server.
You can also use the WebDAV Browser to upload other files from your filesystem. From the Finder or Windows Explorer, drag a file over the WebDAV Browser and drop it in. It‘s sent to Zope immediately. When you upload a file to Zope, it examines the filename, the content type, and in some cases the body of the file and creates an appropriate Zope object, such as an Image, Document, or File. You can customize how Zope responds to uploaded files allowing it to create custom content components and even vary its behavior depending on where the file is uploaded.
Using WebDAV with Cadaver
You can use an open source WebDAV client calledcadaver to connect to Zope and manage your objects with its command-line interface.
Cadaver runs on any UNIX like operating system. Currently, cadaver is still in development, but it is still very useful and implements most WebDAV features.
Using cadaver is simple. It works much like an FTP client. To connect to a WebDAV server with cadaver, specify a URL argument after the main cadaver program name::
bash$ cadaver www.zope.org:8088/Members/bruce Looking up hostname... Connecting to server... connected. Connecting to server... connected. dav:/>
Now you are at the cadaver command line at Zope.org. You are currently browsing anonymously in your member folder. If you want to do something only a privileged user can do, like add a new image, cadaver will prompt you for a username and password: dav:/Members/michel/> put panel.jpgput panel.jpgUploading panel.jpg to `/Members/bruce/panel.jpg‘: (reconnecting...done)Progress: [=============================>] 100.0% of 69662 bytesAuthentication required for Zope on server `www.zope.org‘:Username: brucePassword:Progress: [=============================>] 100.0% of 69662 bytes succeeded.
 
You can alternate between an editor such as vi, Emacs, or Gimp and cadaver, authoring your content and uploading it. Currently there is no Emacs integration with WebDAV, to match its integration with FTP.
Cadaver has many features, and a interactive help system you can get to by typing "help". Cadaver support properties, locking, and other advanced WebDAV features.
Final Notes On WebDAV
In this section we have looked at the various ways to use WebDAV for distributed authoring in Zope. Even without the "V" (versioning), WebDAV is a leap forward for the two-way web.
There are still issues, though. The "source vs. rendered" problem was mentioned previously. Also, many WebDAV clients don‘t pay much regard for Content-Type and insist on using file extensions to deduce type. This is particularly bad for Zope, as Zope‘s tradition is, like the Mac, to eschew file extensions. It‘s worse for Zope, though, as Zope has an extremely flexible and extendible concept of "type".
DAV properties are another area where current implementations come up short. Again, Zope has a rich idea of properties, far richer than those supported by most filesystems. None of the current tools allow inspection, much less setting, ad hoc properties.
Now that we‘ve looked at the basics for authoring Zope content through familiar tools, let‘s spend some time understanding what an application server and content management system can do for you.
Conclusion
You can use Zope to author content with FTP and WebDAV as though it were a networked filesystem. However, Zope is much more than a filesystem. Zope objects, unlike normal files, have attributes, behavior, and state. Leveraging this richer content model, Zope provides you with many features:
Membership - You can create and edit your own content through the web. Zope security system allows you to safely delegate control. Templates - You can define website presentation with familiar tools. Zope supports personalized delivery of content. Clustering - Zope provides a cost-effective solution for scalability using commodity hardware and high availability. Content Objects - Zope can support many kinds of smart content including HTML, XML, graphics, Microsoft Office documents, and PDF files. Workflow - You can customize your sites workflow to corredinate the work of content producers. Versioning - You can use Zope‘s history and undo features to track changes, and recover from mistakes. Catalogging - Zope comes with a built-in search engine that provides fast cross-content searching. Extensibility - You can extend Zope with simple scripts in Python and Perl, and you can completely customize the application itself. Syndication - You can syndicate content to other sites, and access syndicated content. Web Services - Zope allows you to access network services and provide network services using XML-RPC. Integration - Zope integrates with many relational databases, and web servers.
In short, Zope offers a complete platform for content management. Happily as a content producer you don‘t need to be aware of any of these features. You can use Zope via FTP or WebDAV and let Zope take care of the rest.
_xyz