Project

General

Profile

« Previous | Next » 

Revision 3108

Added by perry almost 18 years ago

some quick additions and fixes to the python metacat readme

View differences:

src/python/README
1 1
PyMetacat 
2
Python library to work with Metacat XML Databases.
2
Python client library to work with Metacat XML Databases.
3 3
Author: Matthew Perry
4 4
Date: 12/06/2006
5 5

  
......
11 11
Installation
12 12
------------
13 13

  
14
To install pymetcat, copy the metacat.py file into your python site-packages directory (or anywhere in $PYTHONPATH ).
14
To install pymetcat, copy the metacat.py file into your python site-packages directory (eg. /usr/lib/python2.4/site-packages) or anywhere in $PYTHONPATH  including the current working directory.
15 15

  
16 16

  
17 17
Examples
......
19 19

  
20 20
Along with transferEml.py (a full working example of pymetacat usage), here are some basic usage examples:
21 21

  
22
##########################################################################################
22

  
23

  
24
# Load the metacat library
23 25
import metacat
24 26

  
25
# Initialize
27
# Initialize a metacat client connection
26 28
mc = metacat.MetacatClient('www.server.net','/context/metacat')
27 29

  
30
# Inspect the methods available through the MetacatClient object
31
dir(mc)
32

  
28 33
# Print the url
29 34
print mc.getMetacatUrl()
30
# http://www.server.net/context/metacat
31 35

  
32 36
# Login
33 37
response = mc.login('uid=user,o=ORG,dc=ecoinformatics,dc=org','PassW0Rd!')
......
36 40
# Read the eml 
37 41
docid = 'org.99.4.1'
38 42
eml = mc.read(docid)
39
#print eml
43
print eml
40 44

  
41 45
# Insert the read document as a new copy w/ new docid
42 46
newdocid = 'anotherorg.905'
......
61 65
      <returnfield>dataset/title</returnfield>
62 66
      <returndoctype></returndoctype>
63 67
      <querygroup operator="UNION">
64
              <queryterm casesensitive="false" searchmode="contains">
65
                <value>%</value>
66
              </queryterm>
67 68
        <queryterm casesensitive="false" searchmode="contains">
69
          <value>%</value>
70
        </queryterm>
71
        <queryterm casesensitive="false" searchmode="contains">
68 72
          <value>Africa</value>
69 73
          <pathexpr>keyword</pathexpr>
70 74
        </queryterm>
......
72 76
    </pathquery> 
73 77
"""
74 78
response = mc.squery(pathquery)
75
print "==============="
76 79
print response
77
print "==============="
78 80

  
79

  
80 81
response = mc.logout()
81 82
print "logout : ", response
82
#########################################################################################

Also available in: Unified diff