X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Fstorage%2Fmodel.py;h=fcbb1ff1ad5e0e9414f36d2524c36a0b276f951a;hb=b7d6a80faf23cb019c74e65c2264e215446f84a3;hp=810af6b0760e947eaa73dd46a6f3747591fe8591;hpb=e11df870ed7f3739af715a6b744b96c7b15fd974;p=sfa.git diff --git a/sfa/storage/model.py b/sfa/storage/model.py index 810af6b0..fcbb1ff1 100644 --- a/sfa/storage/model.py +++ b/sfa/storage/model.py @@ -111,6 +111,8 @@ class RegRecord (Base,AlchemyObj): record_id = Column (Integer, primary_key=True) # this is the discriminator that tells which class to use classtype = Column (String) + # in a first version type was the discriminator + # but that could not accomodate for 'authority+sa' and the like type = Column (String) hrn = Column (String) gid = Column (String) @@ -136,12 +138,12 @@ class RegRecord (Base,AlchemyObj): if dict: self.load_from_dict (dict) def __repr__(self): - result="[Record id=%s, type=%s, hrn=%s, authority=%s, pointer=%s" % \ + result=""," email=%s"%self.email) + result += ">" + return result + + @validates('email') + def validate_email(self, key, address): + assert '@' in address + return address + + # xxx this might be temporary + def normalize_xml (self): + if hasattr(self,'keys'): self.reg_keys = [ RegKey (key) for key in self.keys ] + +#################### +# xxx tocheck : not sure about eager loading of this one +# meaning, when querying the whole records, we expect there should +# be a single query to fetch all the keys +# or, is it enough that we issue a single query to retrieve all the keys +class RegKey (Base): + __tablename__ = 'keys' + key_id = Column (Integer, primary_key=True) + record_id = Column (Integer, ForeignKey ("records.record_id")) + key = Column (String) + pointer = Column (Integer, default = -1) + + def __init__ (self, key, pointer=None): + self.key=key + if pointer: self.pointer=pointer + + def __repr__ (self): + result="