Skip to content

Commit

Permalink
Fixed bug in eu_register.py that caused an error when POSTING due to …
Browse files Browse the repository at this point in the history
…record_id.
  • Loading branch information
Nathaniel Watson authored and Nathaniel Watson committed May 10, 2018
1 parent 5fe137f commit 023a5e6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
8 changes: 4 additions & 4 deletions encode_utils/MetaDataRegistration/eu_register.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@ def create_payloads(profile_id, infile):
# right type when generating the payload (dict).
schema = profile.get_profile()
schema_props = schema["properties"]
schema_props.update({RECORD_ID_FIELD: 1}) # Not an actual schema property.
field_index = {}
fh = open(infile, 'r')
header_fields = fh.readline().strip("\n").split("\t")
Expand All @@ -217,9 +216,10 @@ def create_payloads(profile_id, infile):
skip_field_indices.append(fi_count)
continue
if field not in schema_props:
raise Exception(
"Unknown field name '{}', which is not registered as a property in the specified schema at {}.".format(
field, profile.profile_id))
if field != RECORD_ID_FIELD:
raise Exception(
"Unknown field name '{}', which is not registered as a property in the specified schema at {}.".format(
field, profile.profile_id))
field_index[fi_count] = field

line_count = 1 # already read header line
Expand Down
6 changes: 3 additions & 3 deletions encode_utils/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ def get_lookup_ids_from_payload(self, payload):
# return response.json()
# response.raise_for_status()

def get(self, rec_ids, ignore404=True, frame="object"):
def get(self, rec_ids, ignore404=True, frame=None):
"""GET a record from the Portal.
Looks up a record in the Portal and performs a GET request, returning the JSON serialization of
Expand Down Expand Up @@ -1006,9 +1006,9 @@ def patch(self, payload, raise_403=True, extend_array_values=True):
self.debug_logger.debug("Success.")
response_json = response_json["@graph"][0]
uuid = response_json["uuid"]
profile = eup.Profile(response_json["@id"])
profile_id = eup.Profile(response_json["@id"]).profile_id
# Run 'after' hooks:
self.after_submit_hooks(uuid, profile.profile_id, method=self.PATCH)
self.after_submit_hooks(uuid, profile_id, method=self.PATCH)
return response_json
elif response.status_code == requests.codes.FORBIDDEN:
# Don't have permission to PATCH this object.
Expand Down
1 change: 0 additions & 1 deletion encode_utils/profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ def __init__(self, profile_id):
#: A list of the property names that are writable, which are those that don't fall into the
#: self.non_writable_props category.
self.writable_props = []

for i in self.properties:
if self.is_prop_not_submittable(i) or self.is_prop_read_only(i):
self.non_writable_props.append(i)
Expand Down

0 comments on commit 023a5e6

Please sign in to comment.