Package bscw :: Package api :: Module ap_get_attributes
[hide private]

Module ap_get_attributes

Get attributes of object (and contained objects until level 'depth') as
list of dictionaries (structs). The entries in these dictionaries depend
on the type of attribute (see functions 'make_*'). The list can be
nested with the content of every container as a list of its own.

It is possible to read the list in pieces ('number' items from 'offset',
with 'number' == 0 meaning the remainder).
The list can be sorted according to the attribute name given in
'sorted_by' (only for 'depth' == 1). With a prepended '-' in
'sorted_by' the list is sorted in descending order.

Metadata attributes are read from object or object.metadata and
can be accessed by object.meta_get(key).

By using 'flter', only contained objects that pass the given filter will be
returned. content_size is manipulated to reflect this. For a list of valid
filters, see bs_object_filters.py.
The 'marker_flter' feature relies on the same filters as 'flter', but does not
affect the length of the output list. Instead, only objects that match the
'marker_flter' are returned with a pseudo-attribute 'marker', while other are
still returned, but without the 'marker' attribute. This feature allows
downloading a content list and afterwards applying a second filter on the
*client side*, though still relying on *server decisions*.

The object_id can be an id like 'bs_30822' or '30822' or a key like
'u_klein'.

You can get the id of a users home folder by calling:
    home_id = s.get_attributes('u_api1', ['home'])[0]['home']['__id__']

You can get the id of the calling users home folder by calling:
    home_id = s.get_attributes()[0]['__id__']


API definition::

 API = (('object_id', 'ASCII string', 0),
        ('attribute_names', 'array', 0, [('item', 'ASCII string', 1)]),
        ('depth', 'int', 0),
        ('nested', 'boolean', 0),
        ('offset', 'int', 0),
        ('number', 'int', 0),
        ('sorted_by', 'ASCII string', 0),
        ('flter', 'ASCII string', 0),
        ('marker_flter', 'ASCII string', 0),
        ('period', 'ASCII string', 0))

Fraunhofer FIT and OrbiTeam Software, (c) 2002-2009


Version: $Rev: 24964 $

Functions [hide private]
 
param_def()
return the parameter definition
 
return_def()
return the result definition (NOT for nested=True)
 
xsd_return_def()
return the result definition for op_soap_from_xapi
 
do_it(request, object_id=None, attribute_names=['__id__', 'name'], depth=0, nested=False, offset=0, number=0, sorted_by=None, flter=None, marker_flter=None, period=None)
see above
 
get_id(obj)
get id of object
 
construct_flter_func(flter)
Parse flter and return a callable filter func(obj)
 
get_attributes(request, obj, items=['__id__', 'name'], depth=0, nested=0, offset=0, number=0, sorted_by=None, flter=None, marker_flter=None, period=None, keep_obj=False)
return attributes of object
 
filtered_allowed_entries(request, obj, flter=None, period=None)
 
parse_method(method)
 
get_period(request, period)
Converts a given period string to a pair of utc timestamp boundaries.
 
get_data(request, obj, items, flter=None, marker_flter_func=None, period=None)
return attributes of object
 
get_container(request, container, items, depth=0, nested=0, memo={}, flter=None, marker_flter_func=None, period=None)
return content of container
 
get_attr(request, obj, item, metadata=None, as_string=False, flter=None, period=None)
return item of object
 
has_sub_container(obj)
return true if the object is a container and has at least one sub container
 
call_get(self, key)
call get function of object eg (for key 'attrx'): self.get_attrx()
 
get_metadata(obj, metadata, item)
return unqualified metadata item of object (try default namespace, usernamespace)
 
make_namespace_dict(obj, item)
return metadata dictionary of object
 
is_container(obj, mustbe=0)
return True if the object is a container else return False (or raise an xmlrpclib.Fault exception if mustbe is not 0)
 
make_object(obj, depth=3, as_string=None)
for cl_persist.Object return dictionary with '__id__' and 'name' of object for other objects return dictionary with fields of object until level 'depth' lists and dictionaries are returned until level 'depth'
 
make_user(obj, as_string=False)
return dictionary with '__id__' and 'name' of object (owner owners creator)
 
make_date(time, GMT=1, as_string=False, as_naive=False)
return xmlrpclib.DateTime in UTC time If time is a naive datetime object or a timetuple, it must be in UTC unless GMT is set to false.
 
make_notes(obj)
return id of object (notes)
 
make_rating(obj)
return dictionary with 'ratings' and 'median' of object (ratings)
 
make_quota_map(obj)
return dictionary with quota usage and limits (quota_accu)
 
make_event(event, context=None, as_string=False)
return dictionary with 'id', 'date', 'who' and 'name' of event (lastEvent createEvent lastChange lastMove)
 
compare_item(a, b)
compare function for sort
 
get_presence_state(obj, idletime)
 
get_presence(request, obj, index=0)
 
get_idletime(request, obj, index=1)
Variables [hide private]
  log_api = logging.getLogger('api')
  get = Action_get
  info = Action_info
  NON_DISCLOSE = ['ldap_passwd', 'password', 'passwd5', 'access_...
  DISCLOSE_NON_INFO = set(['__class__', '__id__', 'content_size'...
  DISCLOSE_NON_GET = set(['__id__', 'icon_path', 'name'])
  ignore_CantCommit = True
  arg_pat = re.compile(r'([^\(\),]*)\(?([^\)]*)\)?')
  unavailable = 0
  online = 1
  out_of_office = 2
  dont_disturb = 4
  in_conference = 8
  available = 1
  recently = 16
  inactive = 16
  __package__ = 'bscw.api'
Function Details [hide private]

get_period(request, period)

 
Converts a given period string to a pair of utc timestamp boundaries.
The parameter 'period' has the following format:
   <period>      ::= <period-spec> + ['(' + <iso8601date> + ')']
   <period-spec> ::= {'day'|'week'|'month'|'quarter'|'year'}
Examples:
  + 'day' or 'day()' returns boundaries of today
                     (in current user's time zone!)
  + 'day(20090724)'  returns the day boundaries of the ISO-8601
                     date '20090724'
                     (in current user's time zone!)

make_object(obj, depth=3, as_string=None)

 

for cl_persist.Object return dictionary with '__id__' and 'name' of object for other objects return dictionary with fields of object until level 'depth' lists and dictionaries are returned until level 'depth'

or

if as_string: as above, but for cl_persist.Object return its name instead

make_user(obj, as_string=False)

 

return dictionary with '__id__' and 'name' of object (owner owners creator)

or

return the user name as string

make_date(time, GMT=1, as_string=False, as_naive=False)

 

return xmlrpclib.DateTime in UTC time If time is a naive datetime object or a timetuple, it must be in UTC unless GMT is set to false. If GMT is false return a naive xmlrpclib.DateTime unless time has a tzinfo or time is a float. (ctime mtime atime last_verified start end lastlog)

or

If as_naive: Always return a naive xmlrpclib.DateTime by applying the user's timezone.

or

If as_string: Return formatted date as string.

make_event(event, context=None, as_string=False)

 

return dictionary with 'id', 'date', 'who' and 'name' of event (lastEvent createEvent lastChange lastMove)

or

return the event description as a string


Variables Details [hide private]

NON_DISCLOSE

Value:
['ldap_passwd', 'password', 'passwd5', 'access_key']

DISCLOSE_NON_INFO

Value:
set(['__class__',
     '__id__',
     'content_size',
     'date_user_duration',
     'date_user_end',
     'description',
     'end',
     'icon_path',
...