[Zapp-cvs-commit] ZApp/help add_zapp_app.jpg,NONE,1.1 person_track_app_list.jpg,NONE,1.1 ZApp.stx,1.
Brought to you by:
sspickle
|
From: Steve S. <ssp...@us...> - 2006-01-05 12:01:27
|
Update of /cvsroot/zapp/ZApp/help In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32162/help Modified Files: ZApp.stx Added Files: add_zapp_app.jpg person_track_app_list.jpg Log Message: adding more docs --- NEW FILE: person_track_app_list.jpg --- (This appears to be a binary file; contents omitted.) --- NEW FILE: add_zapp_app.jpg --- (This appears to be a binary file; contents omitted.) Index: ZApp.stx =================================================================== RCS file: /cvsroot/zapp/ZApp/help/ZApp.stx,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ZApp.stx 3 Jan 2006 20:00:23 -0000 1.4 --- ZApp.stx 5 Jan 2006 12:01:18 -0000 1.5 *************** *** 124,126 **** context.registerBaseClass(PTRK_Person) ! This is a bare-bones template that you can expand on to build your class. \ No newline at end of file --- 124,193 ---- context.registerBaseClass(PTRK_Person) ! This is a bare-bones template that you can expand on to build your class. ! First, let's add the properties mentioned before. Persistent properties of ! our objects are established by providing the ZApp_Base class method 'extendProperties' ! with a LeverPropertyCollection (called 'props' in the source) that contains all ! the properties (LeverProperties really) that specify the names and attributes ! of the various properties. Edit the code that sets up the property ! collect so that it looks like this:: ! ! props = lpcol([ ! lprop(id='last', dbSize=25), ! lprop(id='first', dbSize=10), ! lprop(id='middle', dbSize=1), ! lprop(id='gender', dbSize=1), ! lprop(id='birthdate', prop_type='date'), ! ] ! ) ! ! We'll get to the options for LeverProperties later, for now notice ! that each property needs an 'id' (and be sure to avoid built-in Zope ! properties like 'id' and 'title'.) If the type is not string, use ! the 'prop_type' keyword to specify. If the size is important (e.g., ! if you're using an sql backend) you can specify the maximum property ! size by using the 'dbSize' keyword. ! ! While we're in here.. let's create an object method that 'computes' a ! "fullname" string that can be used by our application. Add a method ! to the PTRK_Person class like this:: ! ! def fullname(self): ! """compute the full name of a person.""" ! ! return "%s, %s %s." % (self.last, self.first, self.middle) ! ! This permits us to 'compute' the full name of a person object at any time ! by calling the person object's 'fullname()' method. ! ! ! Plugging The Class Into Zope ! ! Now that we have a class defined, let's plug it into the Zope ! framework. First, in the Zope instance home 'Products' directory, ! make a link to the 'PersonTracker' directory where your ! PTRK_Person.py class is defined. Then, restart Zope in 'debug mode' ! from the command line. When Zope is starting it scans the Products ! directory for classes that can be used by Zope to build ! applications. If there are any problems in loading the class, Zope ! should complain in the command line output where you started Zope. ! ! If there are no problems, go to the Zope Management Interface (ZMI) ! and pick a spot where you'd like to create your new application. ! Go to the "Select Type To Add" popup, and choose "Z App Application". ! You should see a form something like this: ! ! "Adding ZApp Application":img:add_zapp_app.jpg ! ! There is a popup to choose the flavor of "lever methods" you ! want to use. A lever method is basically just a scheme for ! using the class properties to automatically build backend schema ! and a developer UI for you. In order to do this, the ZApp application ! needs to know which backend you'll be using for your peristent storage. ! I'm going to choose postgresql, for reasons that will become clear later. ! After creating the ZApp application you should see that it contains ! the following templates: ! ! "ZApp Application Templates":img:person_track_app_list.jpg ! ! ! \ No newline at end of file |