version.py 640 B

1234567891011121314151617181920212223242526
  1. from flask import g, current_app
  2. from rdflib import Graph
  3. from lakesuperior.model.ldp_nr import Ldpc
  4. class Version(Ldpc):
  5. '''
  6. A resource version.
  7. '''
  8. def __init__(self, parent_uuid, label):
  9. self.uuid = parent_uuid + '/' + label
  10. self.urn = nsc['fcres'][uuid]
  11. self.uri = g.tbox.uuid_to_uri(self.uuid)
  12. self.rdfly = current_app.rdfly
  13. self.parent_urn = nsc['fcres'][parent_uuid]
  14. self.label = label
  15. def create(self):
  16. if not self.rdfly.ask_rsrc_exists(self.parent_urn):
  17. add_gr = Graph()
  18. self._modify_rsrc(self.RES_CREATED, add_trp=add_gr)