File tree 2 files changed +15
-1
lines changed
2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -193,6 +193,20 @@ def register_or_update(
193
193
if f"{ link_prefix } _{ scheme } " in links :
194
194
url = links [f"{ link_prefix } _{ scheme } " ]
195
195
196
+ # NOTE: This is not the best place to do this, since we shouldn't be aware of
197
+ # the fact that the record has a `RelationsField``. However, without
198
+ # dereferencing, we're not able to serialize the record properly for
199
+ # registration/updates (e.g. for the DataCite DOIs).
200
+ # Some possible alternatives:
201
+ #
202
+ # - Fetch the record from the service, so that it is already in a
203
+ # serializable dereferenced state.
204
+ # - Bake-in the dereferencing in the serializer, though this would
205
+ # be not very consistent regarding the architecture layers.
206
+ relations = getattr (pid_record , "relations" , None )
207
+ if relations :
208
+ relations .dereference ()
209
+
196
210
if pid .is_registered ():
197
211
self .require_permission (identity , "pid_update" , record = record )
198
212
pid_manager .update (pid_record , scheme , url = url )
Original file line number Diff line number Diff line change @@ -71,7 +71,7 @@ def __getattr__(self, name):
71
71
72
72
objs = super ().__getattribute__ ("_objs" )
73
73
for o in objs :
74
- if getattr (o , name ):
74
+ if getattr (o , name , None ):
75
75
return getattr (o , name )
76
76
raise AttributeError ()
77
77
You can’t perform that action at this time.
0 commit comments