-
Notifications
You must be signed in to change notification settings - Fork 30
Change GeoNodePublishHandler to create / update Layer instances without using geoserver-specific gs_slurp() #65
Conversation
…dler. Added handle() test.
17726d0
to
4d535a5
Compare
3a960f9
to
18749e4
Compare
18749e4
to
4c55185
Compare
@@ -0,0 +1,105 @@ | |||
''' | |||
Created on Nov 9, 2016 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This information is in the git history and doesn't need to be in source files.
''' | ||
Created on Nov 14, 2016 | ||
|
||
@author: jivan |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I strongly prefer that people don't add these attributions to source code...
- It doesn't help anything, since that information is already available in
git blame
. - It adds clutter; if everyone did this for each change, then for example I would have my name in hundreds of places in the tests.
- It raises issues about attribution that are better left to
git blame
. For example, you just wrote at the top of this file "author: jivan". But you did not actually write the original GeoNodePublishHandler. So do we separately attribute your changes vs the original class? It should not even matter anyway because anyone who cares knows what work you did anyway, so why even make the issue salient?
logger = logging.getLogger(__name__) | ||
|
||
|
||
class GeoNodePublishHandler(ImportHandlerMixin): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the benefit of other readers, this mostly moved to osgeo_importer/handlers/geonode/publish_handler.py
where it does have a few changes.
This kind of move does make it harder to do diffs and thus to review things. It would help a little to separate these kinds of opinions about where things should be from the actual implementation. Maybe we should just have some separate PRs for this kind of reformatting
@@ -2,3 +2,6 @@ | |||
python-dateutil | |||
psycopg2 | |||
numpy | |||
|
|||
# Needed for testing | |||
mock |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm OK with including this here (rather than e.g. in a separate dev-requirements.txt
) because in principle it's nice to be able to run unit tests on deployed instances.
@@ -62,9 +62,12 @@ | |||
|
|||
# Note that Django automatically includes the "templates" dir in all the | |||
# INSTALLED_APPS, se there is no need to add maps/templates or admin/templates | |||
try: TEMPLATE_DIRS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Putting this on the same line isn't PEP 8, e.g.
Definitely not:
...
try: something()
finally: cleanup()
# Disconnect the geoserver-specific post_save signal attached to Layer creation. | ||
# The geoserver signal handler assumes things about the store where the Layer is placed. | ||
# this is a workaround. | ||
disconnected_post_save = signals.post_save.disconnect(geoserver_post_save, sender=Layer) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comment helps
] | ||
|
||
# attribute_map gets modified as a side-effect of the call to set_attributes() | ||
expected_results = copy.deepcopy(attribute_map) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of scope, but it would be nice if set_attributes made its own copy to avoid that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trying to stage changes; first change to set_attributes was just to refactor into two pieces for use here, rather than introducing changes in functionality.
'workspace': self.workspace, | ||
'store': store_name, | ||
'storeType': store_type, | ||
'typename': '{}:{}'.format(workspace_name.encode('utf-8'), layer_name.encode('utf-8')), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mildly prefer this to be done prior in its own line but ok
upload_layer.save() | ||
|
||
return results | ||
from publish_handler import GeoNodePublishHandler # NOQA - Moved this code but want it still available here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, it helps to look after these little public API things
@@ -27,15 +27,15 @@ | |||
from osgeo_importer.handlers.geoserver import GeoWebCacheHandler |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For reader context, there are almost no changes between tests.py and tests/tests_original.py.
This is good, because it means I don't have to go hunting for missing things, so never mind about that.
@harts-boundless Thanks for your comments. Which do you consider blockers to a merge? |
…ings. Set typename prior to use.
Assuming all Travis checks pass here, it looks like all stopper issues have been addressed. Thanks Sasha for taking the time for such a thorough review. From what I can see this PR looks ready to be merged. |
Tested against Exchange, nothing appears to be broken - also tested with geoserver handlers removed from settings; confirmed that this fixes issue raised in #58 |
Great, thanks! |
Update GeoNodePublishHandler to create/update new GeoNode Layer instances without reliance on geoserver-dependent gs_slurp().