Fix loading repo name from yaml - #63
Conversation
|
|
||
| (book,created) = Book.objects.get_or_create(book_id=int(obj['identifiers']['gutenberg'])) | ||
|
|
||
| if "repo_name" in obj: |
There was a problem hiding this comment.
It's "_repo", not "repo_name". See https://github.com/gitenberg-dev/documentation/blob/master/metadata/pandata_attribute_dictionary.yaml
There was a problem hiding this comment.
The repo_name property comes the load_repos management command, where I add it to the end of the YAML data. See the changes to load_repos.py in this PR. This is how I pass the repo name to the addBookFromYaml function. There doesn't appear to be a "_repo" property that exists on the object created by the BookMetadata constructor. Let me know if I am misunderstanding what you are saying.
There was a problem hiding this comment.
gitenberg.util.catalog.BookMetadata objects are meant to be constructed with gitenberg.book.Book objects. The constructor for these objects takes repo_name as a parameter, if not, it generates the reponame. Your load_repos is constructing with it gitensite.apps.bookinfo.models.Book objects. If you want to duck type it, you need your Book object to mimic the behaviour of the gitenberg.book.Book object.
|
I think it's BookMetadata.metadata._repo |
| metadata=BookMetadata(Book(book_id=pg_id), rdf_library=rdf_library, enrich=should_enrich) | ||
|
|
||
| # Add repo_name to yaml | ||
| yaml = metadata.__unicode__() + "\nrepo_name: " + repo_name |
There was a problem hiding this comment.
this is error-prone in a number of ways. Better to do
metadata.metadata["_repo"] = repo_name
|
|
||
| # Add repo_name to yaml | ||
| yaml = metadata.__unicode__() + "\nrepo_name: " + repo_name | ||
| addBookFromYaml(yaml) |
There was a problem hiding this comment.
note that your code takes a dict, converts it to a yaml string, and then the first line in addBookFromYaml converts the yaml string into a dict
There was a problem hiding this comment.
Ok, I can see the issue here. I will work on restructuring this.
|
OK, now we have changed our approach for the |
The addBookFromYaml function was not loading the repo name into the database, so this PR includes a fix for this issue.