<html><head><title>
POO Directories
</title></head><body><center><h1>
POO Directories
</h1></center>


<p><hr><h2>Introduction to Directories</h2>

POOs (like MOOs) tend to generate a large number of useful (or at least
interesting) objects which you may frequently want to refer to, even
when they are not in your immediate context.  It is convenient to group
such objects into a logical hierarchy, much like a file system.  Thus,
you could group all public objects under "pub", and further divide this
into rooms, for example.  A particular type of room (e.g., exitLister)
is then referred to as <b>$pub.rooms.exitLister</b>.

<p>
There are two ways to accomplish such hierarchies.  One is to simply
set properties on the grouping object which refer to the individuals in
the group.  This is how <b>$usr</b> works; $usr is a simple POO object
which has one property for each user in the server.  $usr.Tim is a
property on this object, which refers to the Tim object.

<p>
Another way to do it is to use <b>Directory</b> objects.  These are a
special type of POO object, which makes anything in its contents act
like a property.  <b>$pub</b> and <b>$sys</b> are Directory objects. 
Anything dropped inside one of these objects instantly shows up on that
object's property list, as if it were a built-in property.  Directory
objects are extremely handy, because they provide both a place to store
objects, and a convenient way to refer to them.

<p><hr><h2>Examining Directories</h2>

<p>In the core database, the <b>@ex</b> command shows you all
properties on an object.  The <b>@dir</b> command is very similar, but
it shows you only those properties which refer to other objects.  This
is the command you'll most commonly use when working with directories
(or pseudodirectories like <b>$usr</b>.)  Try out the following
commands:

<p><tt><ul>
	<li>@dir $root
	<li>@dir $pub
	<li>@dir $pub.misc
</ul></tt>

<p><hr><h2>Creating Directories</h2>

The core database contains a <b>$dir</b> reference to the standard
directory object.  You can create your own directory with the usual
<b>@create</b> command (e.g., <tt>@create $dir as stuff</tt>).

<p>Next, drop your directory in a safe place, such as your home room. 
You might want to make it immobile (<tt>@set stuff.immobile = 1</tt>)
so somebody doesn't walk off with it.

<p>So that you can always reference your directory, no matter where it
is, set a property on yourself that points to it (<tt>@set me.stuff =
stuff</tt> will do the trick).  Now, if your directory is not in the
room or your inventory, you can refer to it as <tt>me.stuff</tt>.
Moreover, as long as your <tt>stuff</tt> property is readable, others
can refer to it as <tt>$usr.yourname.stuff</tt>.

<p>Finally, you'll want to put some stuff in your stuff directory. 
This is simple: when you're in the same room as a directory called
"stuff", you simply type <tt>enter stuff</tt> to enter that directory. 
You will be moved inside the directory object, much like entering a
room.  (Don't worry, directories are a lot bigger on the inside than
they are on the outside!)  Now, anything you drop inside the directory
will act like it's a property of that directory.  While in a directory,
"look" is almost equivalent to "@dir here".  If there are
subdirectories in the room, you can enter them the same way.  To leave
the directory, type <tt>up</tt>.  This will move you to the object
containing the directory (which should be either another directory, or
a room).  <b>Note</b>: you can't enter a directory which you are
carrying; you must drop it first.

<p>That's it!  Now, if you have a widget in your stuff directory, then
no matter where you go, you can refer to <tt>me.stuff.widget</tt>, in
exactly the same way you might refer to <tt>$pub.misc.clock</tt> or
whatever.

<p><hr><h2>Summary</h2>

Directories are a powerful feature for organizing objects, which arise
very naturally from POO and Python property syntax.  As a builder, you
need to understand them at least enough to locate and make use of the
public directories.  And as you acquire a collection of useful objects,
you may find it convenient to organize your own gadgets and gizmos in a
directory hierarchy as well.

<p><hr><address>
http://www.strout.net/python/poo/dirs.html
<br>Last Updated:
2/24/97
. . . . . . <a href="http://www.strout.net/">Joe Strout</a>
</address></body></html>