1 / 132

Time for some Zope

Time for some Zope. What is Zope?. Zope is a web application framework (aka web development framework, [web] application server [framework]) ‏ web application frameworks support users in the development of web applications

jefferyhorn
Download Presentation

Time for some Zope

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Time for some Zope

  2. What is Zope? • Zope is a web application framework (aka web development framework, [web] application server [framework])‏ • web application frameworks support users in the development of web applications • web applications are dynamic – the browser is used to contact a server which runs a program that dynamically creates the page • Zope stands for Z Object Publishing Environment (Z added to create nifty acronym)‏

  3. Benefits of web application frameworks • Allow you to serve dynamic content • Ability to manage site's data, business logic and presentation from a single place • Provide the tools with which you can build a content management system • Provide a framework in which sophisticated e-commerce applications can be created • Provide a mechanism for access control and delegation (separate access for designers, db administrator, programmers of logic...)‏

  4. Benefits of web application frameworks • easy support of producing or consuming web services • support unified view of existing data even if it resides in separate databases, files, etc. • allows application to be scalable across multiple servers

  5. Why Zope? • It's free • It comes with everything (don't have to separately install a database)‏ • You can work with Zope via a web browser • It allows teams of developers to work collaboratively • It provides an extensible security framework • It runs under Linux, Windows, Mac, Solaris, FreeBSD, NetBSD, OpenBSD • It can be extended using the fun language Python

  6. What Zope is not • Zope is not an application that is ready to use out of the box; it is not a web blog, content management system, e-commerce web site (although there are free Zope products that do those things)‏ • Zope is not a visual design tool, like DreamWeaver; you can use a visual design tool in conjunction with Zope (or not)

  7. Object Orientation • Zope is an object-oriented web application framework • URL to a Web resource is a path to an object; HTTP protocol provides a way to send messages to that object and receive its response. • Zope's duty is to "publish" the objects you create

  8. Mapping of URL to object • web browser sends a request to the Zope server; request specifies a URL in the form protocol://host:port/path?querystring • Zope separates the URL into its component "host", "port" "path" and "query string" portions • Zope locates the object in its object database corresponding to the "path" • Zope "executes" the object using the "query string" as a source of parameters that can modify the behavior of the object • If the act of executing the object returns a value, the value is sent back to your browser. Typically a given Zope object returns HTML, file data, or image data

  9. Zope Management Interface • accessed through the web • provides a familiar Windows Explorer-like view of the Zope object system • developer can create and script Zope objects or define new kinds of objects, without requiring access to the file system of the web server • work with objects by clicking on tabs that represent different views of an object; views depend on the type of object (folder, DTML Method object, Database Connection object, etc.)‏

  10. Zope Object Database (ZODB)‏ • Zope objects are stored in a high-performance transactional object database • Each Web request is treated as a separate transaction by the object database • If an error occurs in your application during a request, any changes made during the request will be automatically rolled back • object database also provides multi-level undo, allowing a site manager to "undo" changes to the site with the click of a button

  11. Acquisition • Zope objects are contained inside other objects (such as Folders)‏ • Objects can "acquire" attributes and behavior from their containers • A commonly used SQL query or snippet of HTML can be defined in one Folder and objects in subfolders can use it automatically through acquisition

  12. Zope Components • Zserver – built-in web server • Web Server – can uses to act as proxy for Zserver • Zope Core – acts as the controller • Object Database – basically, contains the website • Relational Database – Zope provides support to work with other databases such as MySQL

  13. Zope Components • File System – Zope can be used to access documents and other files on the server's file system • Zclasses – can be used to define new object types • Products – can add new object types by installing Product files on the Zope server's file system

  14. Zope object terminology • objects – In Zope, folders are objects, control panel is an object, root folder is an object; you use Zope to create new objects • attributes/properties – object data are called attributes or properties • methods – actions that can be performed via objects are methods • messages – objects communicate with each other via messages; messages are sent to objects by way of the object's methods; object sending message is called “sender”; object receiving message is called “receiver”

  15. Zope object terminology • classes – Zope has classes (blueprints for objects); typically, classes from which objects are created are defined in Zope Products • instances – object that is an instantiation of a class • inheritance – inheritance is used extensively; for example, the Zope image class inherits behavior from the Zope File class

  16. Zope object terminology • lifetime of an object depends upon the type of the object • Files, Folders, etc. have a lifetime from creation time to deletion time (called persistent objects)‏ • object that represents a web request (REQUEST) last from the moment that the request is received until the response is sent back • session data – lasts from when created on behalf of user until time to terminate session (for example, after 20 minutes of inactivity)‏

  17. How Zope is different from other servers • typically, it does not server HTML files found on the server's hard drive • objects created via Zope are not stored in files with a .html extension • Instead, objects are stored in a database known as ZODB (Zope Object Database)‏ • ZODB creates a file named Data.fs which stores objects • The Zope Management Interface (ZMI) is the primary way to interact with Zope objects

  18. Zope Management Interface • management and development environment that allows you to control Zope, manipulate Zope objects, and develop web applications • ZMI displays Zope object hierarchy; buttons and links represent actions on objects • To access ZMI, you'll need to: • install Zope • create a Zope instance • execute zopectl start or runzope in the bin directory of your Zope instance • point browser to: http://localhost:8080/manage • enter userid/password used to create instance

  19. ZMI frames • Navigator frame – left frame; allows you to expand and contract a view into the Zope object hierarchy; topmost container is the root folder • Workspace frame – right frame; shows the object you are currently managing; tabs across the top gives you a different view of the current object and perform management tasks; below the tabs is a description of the object and its URL (see next two slides)‏

  20. ZMI frames • Status frame – top frame; displays current login name and a drop-down box that allows you to select: • preferences – allows you to set ZMI preferences (height, width of text, use of style sheets, display of status frame); info stored in browser cookies • logout – this doesn't seem to work on firefox; it displays an authentication box for logging out, but rejects userid and password; just click cancel • quick start links – displays quick start page with links to Zope documentation

  21. Brief Overview of ZMI abilities • adding objects to your Zope instance – choose type from drop-down list in Navigator frame and click on add • moving objects – use cut and paste at bottom of Workspace frame (object doesn't disappear from original location until pasted); must have cookies enabled for this to work • import/export objects – can export any object to an export file; these can be imported (ie., by another Zope installation) by putting export file inside of the import directory and choosing import from ZMI

  22. Adding objects

  23. Brief Overview of ZMI abilities • Undoing transactions • transactional operation – set of changes to objects that are committed in a single batch • in Zope, a single web request initiates transaction; when finished Zope commits the transaction unless an error occurred • transactions can be undone via the Undo tab • transactions are named after the Zope method that initiated them /manage_delObjects – method that deleted a Zope object • can not undo a transaction that a later transaction depends upon (but can undo both)‏

  24. Objects and properties • objects are uniquely defined by their location in the object hierarchy and the object id • you'll be prompted for an object id when you create an object • two objects within the same folder can not have same id • an object can be given properties (attributes) via the properties view • some properties are predefined (like a title property for a folder); you can define and add other properties of different types (useful for metadata, for example)‏

  25. Types of properties • boolean, string, int, long, float, • date – DateTime value • lines – sequence of strings • tokens – list of words separated by spaces • text – multi-line string • selection – HTML select input widget • multiple selection – HTML multiple select input widget • ulines, ustring, utokens – unicode text

  26. ZMI Help • workspace frame contains a help link on the far right • help link causes another browser to be opened containing the help system • leftmost frame contains contents and search tabs (where you can search the documentation -- very helpful; although some documentation is missing)‏

  27. Fundamental Zope objects • Content – documents, images, files with text or binary; Zope can work with content objects in the ZODB or content stored externally like in a relational database (like MySQL)‏ • Presentation – Zope provides objects that act as web page templates • DTML (Document Template Markup Language) allowing you to mix presentation and logic • ZPT (Zope Page Template) – logic not part of presentation • Logic – logic can be scripted in Python, DTML and Perl (with a Zope add-on)‏

  28. Content Objects: Files, Folders, Images • Files – contain raw data; can use Files to hold any kind of information that Zope doesn't specifically support (Flash files, Java applets, etc.)‏ • content type is expressed by MIME designation (“application/pdf”, “text/plain”, etc.)‏ • Zope tries to guess content type when you upload the file • create File by selecting File from Zope's Add list; use browse button to upload file from local server

  29. Content Objects: Files, Folders, Images • Files, continued • if you click on the name of the file in the workspace frame, you'll be shown the edit view • can change content type of the file if Zope guessed wrong • can specify precondition for a file – name of executable Zope object that must be executed before the file is viewed or downloaded • can change contents of existing file by selecting new file and clicking upload • if file holds only text and its size is <64 bytes, Zope will display a textarea and allow you to change file

  30. Content Objects: Files, Folders, Images • Folders – only purpose is to hold other objects and as noted earlier, folder names correspond to the path component in URL • Images – Images are similar to File objects but include extra behavior for managing graphic content (info about uploading files on earlier slides also applies to images)‏

  31. Presentation objects: ZPT and DTML objects • Zope Page Templates (ZPT) – allows you to define dynamic presentation by inserting special XML namespace elements into the HTML which define dynamic behavior of the page; pages created or XML/XHTML compliant • Document Template Markup Language (DTML) – allows you to define presentation for a web page; special tags in the HTML define the dynamic behavior for the page (all dynamic behavior defined in the page)‏

  32. When to use DTML • creating a set of dynamic web pages that share bits of content with each other • aren't working on a project that calls for a tremendous amount of collaboration between programmers and tool-wielding designers • want to dynamically create non-HTML text (like CSS stylesheets or email messages)

  33. When to use ZPT • want code which expresses a set of complex algorithms to be maintainable • only need to create either XML or XHTML • want to ensure that your application produces valid XHTML • Note: for this choice, you'll likely have a Python script to do the complex processing and a ZPT for displaying the result

  34. Logic Objects: Script (Python) Objects and External Methods • logic objects perform calculations in support of presentation objects • when executed, they do not typically return HTML – they return values that are easy for presentation (for example, list of strings)‏ • Two types of logic objects built-in to Zope • Script (Python) objects • External Methods • add-on product allows one to code in Perl

  35. Logic Objects: Script (Python) Objects and External Methods • Script (Python) Objects • weirdly named because of a legal dispute over calling them Python Scripts • written in a subset of the Python scripting language for security reasons – cannot directly access files on the filesystem • created by selecting Script (Python) from the drop-down list next to add in the Workspace window • click on the name in the Workspace window in order to edit it

  36. Logic Objects: Script (Python) Objects and External Methods • Script (Python) Objects • can give the script a name in the edit view Title textbox • give parameters (with default values, if desired) in the Parameter List textbox • Run by clicking on Test (gives input fields for script input)‏

  37. Logic Objects: Script (Python) Objects and External Methods • Script (Python) - • another way to specify the parameters is via “comments” in the script file ##parameters=name=”Cindy” • the double # signs provides information to Zope (you can also provide other information such as the container object via bind directives)‏ • Zope strips off these “comments” when the file is saved • This can be convenient if you are uploading the script from the local server

  38. Logic Objects: Script (Python) Objects and External Methods • External Methods • objects that contain Python code outside of Zope • not editable via Zope and not constrained to Zope's security machinery (they can execute any Python code)‏ • the external method module should be placed in the Extensions subdirectory of your Zope instance • use ZMI add to create an External Method object

More Related