Commit 4804b938 authored by Staiger, Christine's avatar Staiger, Christine
Browse files

Update 07-python-API-for-users.md

parent 9830a9f0
......@@ -351,7 +351,7 @@ One can also give 'write' access or set the 'own'ership.
Collections have a special ACL, the 'inherit' ACL. If 'inherit' is set, all subcollections and data objects will inherit their ACLs from their parent collection automatically.
## Searching for data in iRODS
We will now try to find all data in this iRODS instance we have access to and which carries the key *author* with value *Lewis Carroll*. And we need to assemble the iRODS logical path.
We will now try to find all data in this iRODS instance we have access to and which carries the key *AUTHOR* with value *Lewis Carroll*. And we need to assemble the iRODS logical path.
```py
from irods.models import Collection, DataObject, CollectionMeta, DataObjectMeta
......@@ -361,10 +361,10 @@ We need the collection name and data object name of the data objects. This comma
```py
query = session.query(Collection.name, DataObject.name)
```
Now we can filter the results for data objects which carry a user-defined metadata item with name 'author' and value 'Lewis Carroll'. To this end we have to chain two filters:
Now we can filter the results for data objects which carry a user-defined metadata item with name 'AUTHOR' and value 'Lewis Carroll'. To this end we have to chain two filters:
```py
filteredQuery = query.filter(DataObjectMeta.name == 'author').\
filteredQuery = query.filter(DataObjectMeta.name == 'AUTHOR').\
filter(DataObjectMeta.value == 'Lewis Carroll')
print(filteredQuery.all())
```
......@@ -408,7 +408,7 @@ The *icat_key* is the keyword used in the database behind iRODS to store the inf
**Exercise** What is the database key for a data object's checksum and its size?
**Exercise** How would you retrieve files labeled with the 'author' 'Lewis Carroll' list their checksum and determine their size?
**Exercise** How would you retrieve files labeled with the 'AUTHOR' 'Lewis Carroll' list their checksum and determine their size?
**Solution**
The class *DataObject* carries an attribute *checksum*
......@@ -425,7 +425,7 @@ query = session.query(Collection.name,
DataObject.size,
DataObjectMeta.value)
filteredQuery = query.filter(DataObjectMeta.name == 'author').\
filteredQuery = query.filter(DataObjectMeta.name == 'AUTHOR').\
filter(DataObjectMeta.value == 'Lewis Carroll')
print(filteredQuery.all())
```
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment