oldaplib 0.4.0__py3-none-any.whl → 0.4.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -80,11 +80,14 @@ class DataPermission(PermissionWithValue):
80
80
  DATA_DELETE = ('oldap:DATA_DELETE', 5) # Allow to delete complete resource
81
81
  DATA_PERMISSIONS = ('oldap:DATA_PERMISSIONS', 6) # Allow to modify permissions of resource
82
82
 
83
+ def __str__(self) -> str:
84
+ return self.to_string()
85
+
83
86
  @property
84
87
  def toRdf(self):
85
88
  return self.value
86
89
 
87
- def to_string(self):
90
+ def to_string(self) -> str:
88
91
  return self.name.removeprefix("oldap:")
89
92
 
90
93
  @classmethod
@@ -127,6 +127,7 @@ class ResourceInstance:
127
127
  # we have an attachedToRole property given in the constructor...
128
128
  #
129
129
  value = kwargs[str(prop_iri)] if kwargs.get(str(prop_iri)) else kwargs[prop_iri.fragment]
130
+ value = {Xsd_QName(role): dperm if isinstance(dperm, DataPermission) else DataPermission.from_string(dperm) for role, dperm in value.items()}
130
131
  if not isinstance(value, dict):
131
132
  raise OldapErrorValue(f'{self.name}: Property {prop_iri} with attachedToRole must be a dict')
132
133
  self._attached_roles = ObservableDict(value, on_change=self.__attachedToRole_cb)
oldaplib/src/user.py CHANGED
@@ -892,49 +892,55 @@ class User(Model):
892
892
  # oldap:hasDefaultDataPermission has changed!
893
893
  #
894
894
  rdfstar = False
895
- sparql = f'{blank:{indent * indent_inc}}# RDF*Star <<.. oldap:hasRole ...>> oldap:hasDefaultDataPermission ...\n'
896
- sparql += f'{blank:{indent * indent_inc}}WITH oldap:admin\n'
895
+ sparql = ''
896
+ if removed or changed:
897
+ sparql += f'{blank:{indent * indent_inc}}# RDF*Star DELETE: <<.. oldap:hasRole ...>> oldap:hasDefaultDataPermission ...\n'
898
+ sparql += f'{blank:{indent * indent_inc}}DELETE DATA {{\n'
899
+ sparql += f'{blank:{(indent + 1) * indent_inc}}GRAPH oldap:admin {{\n'
900
+ rdfstar = True
897
901
  if removed:
898
902
  tmp = [role for role, dperm in removed.items() if dperm] # check if we have roles with dterm not None
899
903
  if tmp:
900
- sparql += f'{blank:{indent * indent_inc}}DELETE {{\n'
901
904
  for role, dperm in removed.items():
902
905
  if dperm:
903
- sparql += f'{blank:{(indent + 1) * indent_inc}}<<?user oldap:hasRole {role.toRdf}>> oldap:hasDefaultDataPermission {dperm} .\n'
904
- sparql += f'{blank:{indent * indent_inc}}}}\n'
905
- rdfstar = True
906
+ sparql += f'{blank:{(indent + 2) * indent_inc}}<<{self.userIri.toRdf} oldap:hasRole {role.toRdf}>> oldap:hasDefaultDataPermission {dperm.toRdf} .\n'
906
907
  if changed: # remove RDF*Star triples of the roles that have changed
907
908
  tmp = [role for role, dperm in changed.items() if dperm['old']]
908
909
  if tmp:
909
- sparql += f'{blank:{indent * indent_inc}}DELETE {{\n'
910
910
  for role, changes in changed.items():
911
911
  if changes['old']:
912
- sparql += f'{blank:{(indent + 1) * indent_inc}}<<?user oldap:hasRole {role.toRdf}>> oldap:hasDefaultDataPermission {changes["old"]} .\n'
913
- sparql += f'{blank:{indent * indent_inc}}}}\n'
914
- rdfstar = True
912
+ sparql += f'{blank:{(indent + 1) * indent_inc}}<<{self.userIri.toRdf} oldap:hasRole {role.toRdf}>> oldap:hasDefaultDataPermission {changes["old"].toRdf} .\n'
913
+
914
+ if rdfstar:
915
+ sparql += f'{blank:{(indent + 1) * indent_inc}}}}\n'
916
+ sparql += f'{blank:{indent * indent_inc}}}}\n'
917
+ if added or changed:
918
+ if rdfstar:
919
+ sparql += f'{blank:{indent * indent_inc}};\n'
920
+ sparql += f'{blank:{indent * indent_inc}}# RDF*Star INSERT: <<.. oldap:hasRole ...>> oldap:hasDefaultDataPermission ...\n'
921
+ sparql += f'{blank:{indent * indent_inc}}INSERT DATA {{\n'
922
+ sparql += f'{blank:{(indent + 1) * indent_inc}}GRAPH oldap:admin {{\n'
923
+ rdfstar = True
924
+ else:
925
+ rdfstar = False
915
926
  if added:
916
927
  tmp = [role for role, dperm in added.items() if dperm] # check if we have roles with dterm not None
917
928
  if tmp:
918
- sparql += f'{blank:{indent * indent_inc}}INSERT {{\n'
919
929
  for role, dperm in added.items():
920
930
  if dperm:
921
- sparql += f'{blank:{(indent + 1) * indent_inc}}<<?user oldap:hasRole {role.toRdf}>> oldap:hasDefaultDataPermission {dperm} .\n'
922
- sparql += f'{blank:{indent * indent_inc}}}}\n'
931
+ sparql += f'{blank:{(indent + 2) * indent_inc}}<<{self.userIri.toRdf} oldap:hasRole {role.toRdf}>> oldap:hasDefaultDataPermission {dperm.toRdf} .\n'
923
932
  rdfstar = True
924
933
  if changed: # add the RDF*Star triples of the roles that have changed
925
934
  tmp = [role for role, dperm in changed.items() if dperm['new']]
926
935
  if tmp:
927
- sparql += f'{blank:{indent * indent_inc}}INSERT {{\n'
928
936
  for role, changes in changed.items():
929
937
  if changes['new']:
930
- sparql += f'{blank:{(indent + 1) * indent_inc}}<<?user oldap:hasRole {role.toRdf}>> oldap:hasDefaultDataPermission {changes["new"]} .\n'
931
- sparql += f'{blank:{indent * indent_inc}}}}\n'
938
+ sparql += f'{blank:{(indent + 1) * indent_inc}}<<{self.userIri.toRdf} oldap:hasRole {role.toRdf}>> oldap:hasDefaultDataPermission {changes["new"].toRdf} .\n'
932
939
  rdfstar = True
933
- sparql += f'{blank:{indent * indent_inc}}WHERE {{\n'
934
- sparql += f'{blank:{(indent + 1) * indent_inc}}BIND({self.userIri.toRdf} as ?user)\n'
935
- sparql += f'{blank:{(indent + 1) * indent_inc}}?user a oldap:User .\n'
936
- sparql += f'{blank:{indent * indent_inc}}}}'
937
940
  if rdfstar:
941
+ sparql += f'{blank:{(indent + 1) * indent_inc}}}}\n'
942
+ sparql += f'{blank:{indent * indent_inc}}}}\n'
943
+ if sparql:
938
944
  sparql_list.append(sparql)
939
945
 
940
946
  #
@@ -1115,6 +1121,7 @@ class User(Model):
1115
1121
  self.set_modified_by_iri(Xsd_QName('oldap:admin'), self.userIri, self.modified, timestamp)
1116
1122
  modtime = self.get_modified_by_iri(Xsd_QName('oldap:admin'), self.userIri)
1117
1123
  except OldapError:
1124
+ print(sparql)
1118
1125
  self._con.transaction_abort()
1119
1126
  raise
1120
1127
  if timestamp != modtime:
oldaplib/src/version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.4.0"
1
+ __version__ = "0.4.1"
@@ -699,6 +699,7 @@ class TestUser(unittest.TestCase):
699
699
  AdminPermission.ADMIN_CREATE}},
700
700
  hasRole={Iri('oldap:Unknown'): DataPermission.DATA_RESTRICTED})
701
701
  user.create()
702
+
702
703
  user2 = User.read(con=self._connection, userId="edison", ignore_cache=True)
703
704
  user2.userId = "aedison"
704
705
  user2.familyName = "Edison et al."
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: oldaplib
3
- Version: 0.4.0
3
+ Version: 0.4.1
4
4
  Summary: Open Media Access Server Library (Linked Open Data middleware/RESTApi)
5
5
  License: GNU Affero General Public License version 3
6
6
  Author: Lukas Rosenthaler
@@ -21,7 +21,7 @@ oldaplib/src/enums/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuF
21
21
  oldaplib/src/enums/action.py,sha256=aL7XXmoZ63_L2TTR37vqHpPPf5H_kYiPunNyiSDN28U,828
22
22
  oldaplib/src/enums/adminpermissions.py,sha256=nn76g2E8TIhkiVbZ64LGt81NuPwFXIDRISKBV6l9dyM,1969
23
23
  oldaplib/src/enums/attributeclass.py,sha256=Lc7OnMMl9vjXj0SuL0l30iEjwC3oWDv_C8PFeTavDGc,3006
24
- oldaplib/src/enums/datapermissions.py,sha256=K6fEHstkuQPrQAmz1oFF-dz6lumLFd3Tb1njdgQwg4A,4034
24
+ oldaplib/src/enums/datapermissions.py,sha256=MiaVHXzNDKTGnZJ9pvs-IgQotyV4wA3X484s2RVMOvs,4104
25
25
  oldaplib/src/enums/externalontologyattr.py,sha256=H7SrWrhe1Dkz_t1OFCWZVh3_14lJDltYGh3dOFr1Z6w,807
26
26
  oldaplib/src/enums/haspropertyattr.py,sha256=Pwi-520nxue3s1fku9x4FNFBOOKSbYVI9MTVGD5jaeU,726
27
27
  oldaplib/src/enums/language.py,sha256=OfQsFpIBj8lGBbZEqVCR_1F-bimPM48vqBl4EKBgggY,4623
@@ -59,7 +59,7 @@ oldaplib/src/helpers/tools.py,sha256=sNbiOLucTGNFzZmiWwPLFOb80VTXQH0Zd9uCGubhzAk
59
59
  oldaplib/src/iconnection.py,sha256=XlOc2Kh4tK_UOHydLQwlWjUFLUze-Aq_vEZpf9KS1-s,3677
60
60
  oldaplib/src/in_project.py,sha256=ZnfeOFwpdPh1oyC2mAGH8DnSD9afxYtvsh7_GrfGVgQ,10663
61
61
  oldaplib/src/model.py,sha256=VACR3T6zJYFaE5J1PFFdP0OSwhbu4sahoLMWg6_L_rE,19267
62
- oldaplib/src/objectfactory.py,sha256=V7q6RVEY9HL1y_Qn3OAcYql3Nvv8JvJ7Fox4xbgAACw,85809
62
+ oldaplib/src/objectfactory.py,sha256=3xzXXVRBLernA-JD3NHZ2-FLaywWI6opWIaJfLGv2uk,85975
63
63
  oldaplib/src/oldaplist.py,sha256=s5afrHtUnvDfMUFoZTt-jMxlBlmK2c0tLeTMp0KiIfg,43077
64
64
  oldaplib/src/oldaplist_helpers.py,sha256=D_X7KdFjPNlX-OwR04D6onxhFucrGo8052WuJPRjLkA,14213
65
65
  oldaplib/src/oldaplistnode.py,sha256=NnC2juEGTtEkDO6OlB9PjSw_zTF-wSsRUgEk-6VV9DA,87344
@@ -68,9 +68,9 @@ oldaplib/src/project.py,sha256=ic0cIYYcPk--7XsfbymuGkFbiUFmFJqNgjTWY2Rws7Q,35266
68
68
  oldaplib/src/propertyclass.py,sha256=ez_AyaX_UMIFgSW0msmhOtxXdSB6__pyxVID7Mi6OxU,97241
69
69
  oldaplib/src/resourceclass.py,sha256=E_CT3MKgFyLUtvtrUtRU7sV5s0TPwxEb6l74PsnbgrI,103724
70
70
  oldaplib/src/role.py,sha256=AWtZx80OVERT2xbKeuP8g32VSXkm4MVlzeUWd9nh6mQ,30741
71
- oldaplib/src/user.py,sha256=S5lNqPt0vcagHt2sTuz07GzdisTndNLN1fdRH_PQbYY,55647
71
+ oldaplib/src/user.py,sha256=iTJzSvR0xfc3FFkoKG-q5LptkWB_PGpRGpG-L3271z8,55833
72
72
  oldaplib/src/userdataclass.py,sha256=4kWktau9XSv5alfEVuOvikfxnSSUSKT8cw77TWdMhQM,13921
73
- oldaplib/src/version.py,sha256=1NSg4yHgqJJKYBklxFwmel_5eSNX51umiqsyFgx4770,21
73
+ oldaplib/src/version.py,sha256=IfrBKs_W4usv6LOPMiFXYlA5wFjjr8eb0zFW3FWiUtM,21
74
74
  oldaplib/src/xsd/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
75
75
  oldaplib/src/xsd/floatingpoint.py,sha256=rDReKqh0mXyc4F5wslgTUxbeGf3-PGERyughj5_62YI,8852
76
76
  oldaplib/src/xsd/iri.py,sha256=w1Dr0z-REi7yPe3GPGnyzGrLVMvLY03kEeK-AmZ9sxw,8383
@@ -138,7 +138,7 @@ oldaplib/test/test_propertyclass.py,sha256=MaHoTy7o6b3c44whYWTqG0mCOaNvZqL0Mzf7v
138
138
  oldaplib/test/test_resourceclass.py,sha256=CmCw06meGsLX9-GM_opSf_HyD-Oc_2NQjH1wuhK2lds,96552
139
139
  oldaplib/test/test_role.py,sha256=mr4uNkamfb8T8ehyMf2dfPCXmxe7lvZPdhE-hdB_QN4,19815
140
140
  oldaplib/test/test_semantic_version.py,sha256=OSJYHWDpKBqk-HsxJ2nFpSr14a4OEZTFCogzEni8mcE,3392
141
- oldaplib/test/test_user.py,sha256=5KJsoI6n0muQmKB9Z0Av2eTadLe_RiNmWbITPGtg38g,76599
141
+ oldaplib/test/test_user.py,sha256=S34Y36xz6zgmVkVZf8tg_LkFbw3XkstunjmpjvOa7Fw,76600
142
142
  oldaplib/test/test_xsd_datatypes.py,sha256=Ey2RMMs9a3cNlFe4PHTGcLl5MRlkPBxJTid1NLSe-yg,67959
143
143
  oldaplib/testdata/Gender.yaml,sha256=54ohJWToiuO2rMOUJ85JOsZf2TSrIuPLarHriXa6Lww,235
144
144
  oldaplib/testdata/collections_type.yaml,sha256=03MNQVUoLlq7A1OOtSvACeRs32VfP5eS8av-mPLGoEI,2737
@@ -159,6 +159,6 @@ oldaplib/testdata/source_type.yaml,sha256=dSihKikw3O-IlGf6anj5KWMoBYLaweLVF1Zojm
159
159
  oldaplib/testdata/test_move_left_of_toL.yaml,sha256=2m1OSQrQFlsCQxeJrjzBAO74LMprNDo_HuyrYGsOeXI,787
160
160
  oldaplib/testdata/testlist.yaml,sha256=AT11nXEG81Sfyb-tr1gQV0H_dZBrOCcFuHf7YtL8P2g,1994
161
161
  oldaplib/testit.http,sha256=qW7mnr6aNLXFG6lQdLgyhXILOPN6qc5iFVZclLyVvkY,303
162
- oldaplib-0.4.0.dist-info/METADATA,sha256=1V3ZQ_8Bfm5xczbHFhnjFZZrtOeTFnFgKymXd13Mf74,3009
163
- oldaplib-0.4.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
164
- oldaplib-0.4.0.dist-info/RECORD,,
162
+ oldaplib-0.4.1.dist-info/METADATA,sha256=Lg8EVleImQ28gOXy0FCGdbeqV4GQLAA-_g_yoXlKtfg,3009
163
+ oldaplib-0.4.1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
164
+ oldaplib-0.4.1.dist-info/RECORD,,