-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve base class DatabaseSources #1496
Comments
@mki-c2c Could you explain a little more, what you mean? |
I will give some details about my comments and present some ways forward for improvement. While reviewing the refactoring, I was frustrated that the structure of the data model is reproduced in each abstraction layer:
In particular, I found it quite strange that contrib.source inherits core.source, and in core.source, the only thing which is done is the definition of the record_class So I had the idea of a record class generator. Please refer to the draft PR #1928 for a workin example of what a simplified solution could look like. 1- generic definition of the record class property in the source classthe record class for the data sources can be defined via the config file: the generic data source will read this configuration here: this makes it possible to remove the "intermediate" source files like address.py https://github.com/openoereb/pyramid_oereb/pull/1928/files#diff-b34385f0bc1f2c69ae9c7a17b7eabb6e771eda36e6d201a45478dbaa4037ca7dL1 2- generic readthe read procedure uses the same data structure as in the model definition, no need to re-write it for each class: therefore the data structure is only defined in the DB model and some config file information. 3- recordsthe records can be simplified also because the __init__function is only a copy of the record contents => a python dataclass does the correct initialisation and you only have to declare the contents. ==> conclusion: the demonstrator in the examlpe is incomplete, but single records have been pushed to the end to prove the feasability of a refactoring. |
@mki-c2c wrote:
I have one general remark, not necessarily related to the PR.
The refactoring of DatabaseSources between core and contrib could be improved in the following way:
The base class in core does not rely on
self._record_class_
, but already knows all the attributes to create a record (record.title, record.type, etc.) and there is just a methodself._to_record
which can use the private attributes which have been read from the sources in the children class' read methodOriginally posted by @mki-c2c in #1456 (review)
The text was updated successfully, but these errors were encountered: