Skip to content
This repository has been archived by the owner on Jul 19, 2023. It is now read-only.

Change GeoNodePublishHandler to create / update Layer instances without using geoserver-specific gs_slurp() #65

Merged
12 commits merged into from
Nov 20, 2016

Conversation

JivanAmara
Copy link
Collaborator

Update GeoNodePublishHandler to create/update new GeoNode Layer instances without reliance on geoserver-dependent gs_slurp().

@coveralls
Copy link

coveralls commented Nov 9, 2016

Coverage Status

Coverage decreased (-1.6%) to 83.356% when pulling 374364f on JivanAmara:nogeoserver-geonodemaster into f75b853 on GeoNode:master.

@JivanAmara JivanAmara changed the title Nogeoserver geonodemaster Change GeoNodePublishHandler to create / update Layer instances without using geoserver-specific gs_slurp() Nov 9, 2016
@coveralls
Copy link

coveralls commented Nov 10, 2016

Coverage Status

Coverage decreased (-0.5%) to 84.424% when pulling 579a63c on JivanAmara:nogeoserver-geonodemaster into f75b853 on GeoNode:master.

@JivanAmara JivanAmara force-pushed the nogeoserver-geonodemaster branch from 17726d0 to 4d535a5 Compare November 15, 2016 02:56
@JivanAmara JivanAmara force-pushed the nogeoserver-geonodemaster branch 2 times, most recently from 3a960f9 to 18749e4 Compare November 15, 2016 19:45
@coveralls
Copy link

coveralls commented Nov 15, 2016

Coverage Status

Coverage increased (+0.2%) to 85.18% when pulling 18749e4 on JivanAmara:nogeoserver-geonodemaster into f75b853 on GeoNode:master.

@JivanAmara JivanAmara force-pushed the nogeoserver-geonodemaster branch from 18749e4 to 4c55185 Compare November 15, 2016 22:24
@coveralls
Copy link

coveralls commented Nov 15, 2016

Coverage Status

Coverage increased (+0.2%) to 85.18% when pulling 4c55185 on JivanAmara:nogeoserver-geonodemaster into f75b853 on GeoNode:master.

@@ -0,0 +1,105 @@
'''
Created on Nov 9, 2016
Copy link

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
Copy link

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...

  1. It doesn't help anything, since that information is already available in git blame.
  2. 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.
  3. 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):
Copy link

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
Copy link

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
Copy link

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)
Copy link

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)
Copy link

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

Copy link
Collaborator Author

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')),
Copy link

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.
Copy link

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
Copy link

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.

@JivanAmara
Copy link
Collaborator Author

@harts-boundless Thanks for your comments. Which do you consider blockers to a merge?

@coveralls
Copy link

coveralls commented Nov 18, 2016

Coverage Status

Coverage increased (+0.2%) to 85.187% when pulling dd05400 on JivanAmara:nogeoserver-geonodemaster into f75b853 on GeoNode:master.

@bitner
Copy link
Collaborator

bitner commented Nov 18, 2016

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.

@coveralls
Copy link

coveralls commented Nov 18, 2016

Coverage Status

Coverage increased (+0.2%) to 85.187% when pulling b643b4d on JivanAmara:nogeoserver-geonodemaster into f75b853 on GeoNode:master.

@coveralls
Copy link

coveralls commented Nov 18, 2016

Coverage Status

Coverage increased (+0.2%) to 85.187% when pulling 6433c84 on JivanAmara:nogeoserver-geonodemaster into f75b853 on GeoNode:master.

@sarasafavi
Copy link
Collaborator

sarasafavi commented Nov 20, 2016

Tested against Exchange, nothing appears to be broken - also tested with geoserver handlers removed from settings; confirmed that this fixes issue raised in #58

@ghost
Copy link

ghost commented Nov 20, 2016

Great, thanks!

@ghost ghost merged commit 77f14f7 into GeoNode:master Nov 20, 2016
@ghost ghost mentioned this pull request Nov 28, 2016
@JivanAmara JivanAmara deleted the nogeoserver-geonodemaster branch November 30, 2016 18:51
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants