The PEAK Developers' Center   Diff for "IntroToPeak/LessonTwo" UserPreferences
 
HelpContents Search Diffs Info Edit Subscribe XML Print View Up
Ignore changes in the amount of whitespace

Differences between version dated 2003-12-22 20:54:09 and 2005-02-02 05:16:17 (spanning 7 versions)

Deletions are marked like this.
Additions are marked like this.

 
= Lesson Two: Domain Models and Data Retrieval =
 
Now its time to go a tiny step beyond the triviality of the "Hello,
Now it's time to go a tiny step beyond the triviality of the "Hello,
world!" example. In this chapter I'll expand the example to handle
saying hello to an arbitrary variety of things. Since we want to
be flexible. we'll get the greeting message for each thing from a

it `commands.py`.
 
To accomodate this change to a package, we need to change our
`hello` ini file as follows: {{
`hello` ini file as follows: {{{
#!/usr/bin/env peak runIni
 
[peak.running]

to other kinds of objects. In PEAK-speak, the objects are called
"Elements", and the relationships are called "Features". Features are
implemented as object attributes, using custom descriptors.
See the GraphvizTutorial for more info on Domain Models.
 
To facilitate grabbing data from our database, we'll define a simple
Element class, in a `model.py` file in our helloworld package: {{{

`Message` objects will have once loaded. I think their purposes
should be pretty obvious.
 
You probably noticed immediatly that we are defining classes inside
You probably noticed immediately that we are defining classes inside
classes here. The nested classes actually create attribute descriptors,
similar to the Python built-in `property` type. However, instead of
having to define functions and then wrap them into `property` object,

 
world | Hello, world!
Fred | Greetings, good sir.
Klause | Guten Aben, Herr Klause.
Klause | Guten Abend, Herr Klause.
 
}}} (Forgive my feeble attempts at Deutsche.)
}}} (Forgive my feeble attempts at Deutsch.)
 
Because this is going to be a read-only file, we're going to cheat and
load the file only once, the first time it's used. We'll use another

% ./hello Fred
Greetings, good sir.
% ./hello Klause
Guten Aben, Herr Klause.
Guten Abend, Herr Klause.
 
}}}
 

PythonPowered
ShowText of this page
EditText of this page
FindPage by browsing, title search , text search or an index
Or try one of these actions: AttachFile, DeletePage, LikePages, LocalSiteMap, SpellCheck