My favorites | Sign in
Project Logo
                
Search
for
Updated Jan 02, 2007 by whit537
QuickStart  
Tutorial for getting up and running with Dewey quickly

Requirements & Installation

Tested with Python 2.4 and 2.5

Requires ZODB (tested w/ 3.6)

No release yet, install is currently via svn

Usage

The bundled script takes one argument, which is a ZODB connection string. The connection type defaults to file://, so the easiest thing to do is:

  $ dewey dewey.dat

This will index the current working directory, storing the index in ./dewey.dat. If you successfully start dewey in the source distribution directory, for example, you should get a prompt like this:

  ...
  dewey (  0)> 

Use the "crawl" command to populate the index:

  dewey (  0)> crawl
  ...
  dewey (   53)>

Now you're ready to create a "Collection." Try this:

  dewey (   53)> title is Dewey
  dewey ( 5|53)>

The prompt changes to indicate your current state: 53 total resources known, 5 in the current collection. Now list them:

  dewey ( 5|53)> ls path title nodetype
  
    path                      title                     nodetype
    =============================================================================
    /dewey.dat                Dewey                     file
    /src/dewey                Dewey                     directory
    /build/lib/dewey          Dewey                     directory
    /build/scripts-2.4/dewey  Dewey                     file
    /bin/dewey                Dewey                     file
  
  dewey ( 5|53)>

More Usage

You can also add sort and limit parameters to your collection:

  dewey ( 5|53)> sort path
  dewey [ 5|53]> limit 4
  dewey [ 4\53]> ls path title nodetype
  
    path                      title                     nodetype
    =============================================================================
    /bin/dewey                Dewey                     file
    /build/lib/dewey          Dewey                     directory
    /build/scripts-2.4/dewey  Dewey                     file
    /dewey.dat                Dewey                     file

  dewey [ 4\53]>

And you can add further constraints with AND, NOT, and OR:

  dewey [ 4\53]> AND path below /build
  dewey [ 2/53]> unlimit
  dewey [ 2|53]> ls path title nodetype
  
    path                      title                     nodetype
    =============================================================================
    /build/lib/dewey          Dewey                     directory
    /build/scripts-2.4/dewey  Dewey                     file
  
  dewey [ 2|53]>

You can see the current constraints, sort, and limit with the corresponding commands:

  dewey [ 2|53]> constraints
  title is Dewey
   AND path below /build
  dewey [ 2|53]> sort
  path
  dewey [ 2|53]> limit
  None
  dewey [ 2|53]>

Details

In Dewey, a Collection is a set of filesystem resources constrained by a logical expression in disjunctive normal form. The terms of the expression take the form:

<index> <search> <arg>

Where <index> is the name of an index known to this catalog (try the "indices" command), <search> is a type of query specific to that index, and <arg> is something meaningful to <search>.

The general pattern for programming with Dewey is to build a custom Resource class to represent filesystem resources (one class for all resources), and then define a custom catalog_factory callable that instantiates a dewey.Catalog object and populates it with dewey.indices of your choosing. Attributes of Resource for which there is a corresponding index will be, um, indexed.

After you've initialized your custom catalog, you instantiate the dewey.Collection class to search it. Collection instances are iterable.

You'll also find API on dewey for opening a new catalog, closing a catalog, and controlling a constant-crawl thread.

Start with the dewey script for a more or less complete example. Full docs to follow with an actual release.


Sign in to add a comment
Hosted by Google Code