Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

Download
ActivePython
INSTALL>
pypm install z3ext.pathindex

How to install z3ext.pathindex

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install z3ext.pathindex
 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
1.0.2 Available View build log
Windows (64-bit)
1.0.2 Available View build log
Mac OS X (10.5+)
1.0.2 Available View build log
Linux (32-bit)
1.0.2 Available View build log
Linux (64-bit)
1.0.2 Available View build log
Web
 
Author
License
ZPL 2.1
Depended by
Imports
Lastest release
version 1.0.2 on Jan 5th, 2011

Path index

The PathIndex is an index that index object by it's traversal path

>>> from z3ext.pathindex.index import PathIndex
>>> index = PathIndex()
>>> index.documentCount()
0
>>> index.wordCount()
0
>>> index.maxValue() # doctest: +ELLIPSIS
Traceback (most recent call last):
...
ValueError:...
>>> index.minValue() # doctest: +ELLIPSIS
Traceback (most recent call last):
...
ValueError:...
>>> list(index.values())
[]
>>> len(index.apply({'any_of': (root,)}))
0

We can index traversable object

>>> data = {1: root,
...         2: root['folder1'],
...         3: root['folder1']['folder1_1'],
...         4: root['folder1']['folder1_1']['folder1_1_1'],
...         5: root['folder2'],
...         6: root['folder2']['folder2_2'],
...         7: root['folder2']['folder2_2']['folder2_2_2']
... }
>>> for k, v in data.items():
...     index.index_doc(k, v)

After indexing, the statistics and values match the newly entered content.

>>> len(list(index.values()))
5
>>> index.documentCount()
6
>>> index.wordCount()
5
>>> list(index.ids())
[2, 3, 4, 5, 6, 7]

The index supports five types of query but only 'any_of' is usefulle for PathIndex. The first is 'any_of'. It takes an iterable of values, and returns an iterable of document ids that contain any of the values. The results are weighted.

>>> list(index.apply({'any_of':(root['folder1'],)}))
[3, 4]
>>> list(index.apply({'any_of':(root['folder1']['folder1_1'],)}))
[4]
>>> list(index.apply({'any_of':(root['folder2'],)}))
[6, 7]
>>> list(index.apply({'any_of':(root['folder1'], root['folder2'],)}))
[3, 4, 6, 7]
>>> list(index.apply({'any_of':(
...   root['folder1'], root['folder1']['folder1_1'], root['folder2'],)}))
[3, 4, 6, 7]
>>> print index.apply({'all_of': (root,)})
None
>>> print index.apply({'between': (root,)})
None
>>> list(index.apply({'any': None}))
[2, 3, 4, 5, 6, 7]

We can't index value that doesn't have parents

>>> index.index_doc(100, 'string')
>>> index.apply({'any_of': ('string',)}) is None
True

CHANGES

1.0.2 (2009-03-12)
  • Remove all proxies before trying to query int id for object.
1.0.1 (2008-03-25)
  • Code moved to svn.zope.org
1.0.0 (2008-01-10)
  • Initial release

Subscribe to package updates

Last updated Jan 5th, 2011

Download Stats

Last month:1

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.