Skip to content
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

Added support for load_map_from_string in BaseWMSFactory.loadXML method (2) #27

Merged
merged 3 commits into from Jul 1, 2014
Merged

Conversation

p0cisk
Copy link

@p0cisk p0cisk commented Jun 13, 2014

Hi,
This pull request adds possibility to load mapnik XML configuration from string using load_map_from_string function. There is a check if 'xmlfile' is existing file (os.path.isfile) - if not 'load_map_from_string' will be used.
This is second pull request after #26 - earlier I've add wrong checkig - sorry for that.

Regards
Piotr Pociask

@manelclos
Copy link
Member

Hi Piotr,

Having this would be great for testing. I'd prefer to have this as a different parameter, as both are strings and current one is named xmlfile. Would you mind modifying it to be something like:

def loadXML(self, xmlfile, strict=False, xmlstring=None):

And then xmlstring != None will use it and ignore xmlfile.

What do you think?

@p0cisk
Copy link
Author

p0cisk commented Jun 15, 2014

I doesn't want to adding new parameter in loadXML definition because I want to interfere in the code as little as possible but I'm OK with your suggestion. What do you think to modified it like this:

def loadXML(self, xmlfile=None, strict=False, xmlstring=None):

so user don't need to set xmlfile if he use only xmlstring? It shouldn't also break any earlier compatibility.

@manelclos
Copy link
Member

looks good, can you also create a test so the new code gets covered?

@p0cisk
Copy link
Author

p0cisk commented Jun 21, 2014

Hi
I've changed loadXML definition. load_map_from_string can also have base_path parameter that is useful for supporting relative paths so I also added this to loadXML. If user loads data from files (like Shapefiles) it is good to have this parameter setted.

@manelclos
Copy link
Member

Hi, looks good. One final petition before merge. We should check xmlfile and xmlstring are not both empty, in that case we should raise and Exception explaining one of the two options is mandatory (since we changed xmlfile from mandatory to optional).

@p0cisk
Copy link
Author

p0cisk commented Jun 29, 2014

Is this should rise OGCException, ServerConfigurationError or I should add new exception type?

@manelclos
Copy link
Member

I'd say this is a configuration error.
On 29 Jun, 2014 9:26 PM, "Piotr Pociask" notifications@github.com wrote:

Is this should rise OGCException, ServerConfigurationError or I should add
new exception type?


Reply to this email directly or view it on GitHub
#27 (comment).

@p0cisk
Copy link
Author

p0cisk commented Jun 29, 2014

I've added checking xmlfile and xmlstring variables, test for checking exception and I've clear some unnecessary imports in previous test.

manelclos added a commit that referenced this pull request Jul 1, 2014
Added support for load_map_from_string in BaseWMSFactory.loadXML method (2)
@manelclos manelclos merged commit e839f52 into mapnik:master Jul 1, 2014
@manelclos
Copy link
Member

Perfect! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants