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

Strings are not stripped when importing properties #5

Open
agger-magenta opened this issue Jan 28, 2014 · 3 comments
Open

Strings are not stripped when importing properties #5

agger-magenta opened this issue Jan 28, 2014 · 3 comments

Comments

@agger-magenta
Copy link

I'm importing a Plone site from Plone 3, where several documents and directories have the "layout" property set to direct them to a custom view.

I'm importing in Plone 4 with quintagroup.transmogrifier v. 0.5.

The properties file for one of the documents looks, e.g., like this:

<properties>
  <property name="layout" type="string">
    forf_forside_view
  </property>
</properties>

The document now gets the "layout" property '\n forf_forside_view\n' - which gives us a 404 when trying to view the document, as no view with this name exists.

If the transmogrifier's default export phase insist on formatting the XML with line breaks, I'd expect its import phase to strip the strings before feeding them into the Zope database.

@agger-magenta
Copy link
Author

As it happens, a helper has been added to the file propertymanager.py which is supposed to strip blanks of property values during imports, as is clear from comments in _getNodeText():

        # When properties are extracted newline charcters and indentation were added to
        # them, but these aren't stripped on import. Maybe this method doesn't handle
        # properly multiline string values, but it is needed for importing.

However, this method only strips tag values if the tag is a "text" tag. We need them to strip PROPERTY tags too.

This patch (applicable to v. 0.5) will make import work:

12a13
> 
124a126,127
>                 # MAKE IMPORT WORK!
>                 child.text = child.text.strip()
128a132,133
>                 # MAKE IMPORT WORK!
>                 child.text = child.text.strip()

The changes are in the function _initProperties. They might indeed cause problems for multiline values. There may be a more elegant solution.

@tomgross
Copy link
Member

Hi @agger-magenta Thanks for the patch. Do you have a test case and/or some test data?

@agger-magenta
Copy link
Author

Unfortunately not, as it seems the export from Plone 3 is stranded on my old laptop, which broke.

However, it's very easy to reproduce with any property that has a structure as described in the ticket.

I.e., with the newlines, like

<property name="layout" type="string">
    forf_forside_view
  </property>

'The document now gets the "layout" property '\n forf_forside_view\n' - which gives us a 404 when trying to view the document.'

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

No branches or pull requests

2 participants