from sfa.storage.model import make_record, RegRecord, RegAuthority, RegUser, RegSlice, RegKey, \
augment_with_sfa_builtins
from sfa.storage.alchemy import dbsession
+### the types that we need to exclude from sqlobjects before being able to dump
+# them on the xmlrpc wire
+from sqlalchemy.orm.collections import InstrumentedList
class RegistryManager:
# xxx somehow here calling dict(record) issues a weird error
# however record.todict() seems to work fine
# records.extend( [ dict(record) for record in local_records ] )
- records.extend( [ record.todict(exclude_types=[RegRecord,RegKey]) for record in local_records ] )
+ records.extend( [ record.todict(exclude_types=[InstrumentedList]) for record in local_records ] )
if not records:
raise RecordNotFound(str(hrns))
records = dbsession.query(RegRecord).filter_by(authority=hrn)
# so that sfi list can show more than plain names...
for record in records: augment_with_sfa_builtins (record)
- record_dicts=[ record.todict(exclude_types=[RegRecord,RegKey]) for record in records ]
+ record_dicts=[ record.todict(exclude_types=[InstrumentedList]) for record in records ]
return record_dicts
# fallback
return "** undef_datetime **"
- # it may be important to exclude relationships
+ # it may be important to exclude relationships, which fortunately
+ #
def todict (self, exclude_types=[]):
d=self.__dict__
def exclude (k,v):
if exclude_types:
for exclude_type in exclude_types:
if isinstance (v,exclude_type): return True
- if isinstance (v,list) and v and isinstance (v[0],exclude_type) : return True
return False
keys=[k for (k,v) in d.items() if not exclude(k,v)]
return dict ( [ (k,d[k]) for k in keys ] )