Skip to content

Add import_path to upgradeDepends directive.#124

Draft
mauritsvanrees wants to merge 4 commits into
masterfrom
maurits-upgrade-depends-path
Draft

Add import_path to upgradeDepends directive.#124
mauritsvanrees wants to merge 4 commits into
masterfrom
maurits-upgrade-depends-path

Conversation

@mauritsvanrees
Copy link
Copy Markdown
Member

This avoids the need to register a full profile, when you only need to import a few files once in an upgrade step.

The path must be within the path of a package.
By default this is the path of the profile for which this is an upgrade.
You can also specify a path in a different package: other.package:profile/path.
This is to avoid easy information leaks, like trying to read password files, although the user running the zope process should not have access to sensitive files anyway.

You can combine this with import_steps, but not with import_profile.
Note that metadata.xml is never read, so you cannot use dependencies.

This adds the path keyword argument to several methods, like tool.runAllImportStepsFromProfile and tool.runImportStepFromProfile.

This avoids the need to register a full profile, when you only need to import a few files once in an upgrade step.

The path must be within the path of a package.
By default this is the path of the profile for which this is an upgrade.
You can also specify a path in a different package: ``other.package:profile/path``.
This is to avoid easy information leaks, like trying to read password files, although the user running the zope process should not have access to sensitive files anyway.

You can combine this with ``import_steps``, but not with ``import_profile``.
Note that ``metadata.xml`` is never read, so you cannot use dependencies.

This adds the path keyword argument to several methods, like ``tool.runAllImportStepsFromProfile`` and ``tool.runImportStepFromProfile``.
Copy link
Copy Markdown
Contributor

@d-maurer d-maurer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not like it much:

  • special treatment of metadata.xml
  • new tar support without mention in CHANGES.rst
  • insufficient documentation for new parameter dependency_strategy

I would prefer alternatively an extended way to identify profiles: not only via registration names but also alternatively e.g. via a path. The different ways could be distinguished via prefixes.

Comment thread CHANGES.rst Outdated
By default this is the path of the profile for which this is an upgrade.
You can also specify a path in a different package: ``other.package:profile/path``.
You can combine this with ``import_steps``, but not with ``import_profile``.
Note that ``metadata.xml`` is never read, so you cannot use dependencies.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GenericSetup has 2 kinds of dependencies: "step" and "profile" dependencies. To be specific, I suggest (profile) dependencies in place of dependencies.

Why do you treat metadata.xml specially? Would it not be more natural to view the new feature as just a different way to refer to a profile including the treatment of metadata.xml (if it exists).

Profile ids have the form profile-package:name. This suggests a path alternative of the form path-package:path. It would allow to universally specify profiles via paths: no need to add an additional parameter to several methods, no need to treat metadata.xml specially, True, the parameter profile_id would with this extension better have the name profile_spec, but I think a documentation note of the form: a "profile id" has either the form profile-... or path-... would be sufficient to explain the a profile can be identified either via a registered profile name or a file system path.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GenericSetup has 2 kinds of dependencies: "step" and "profile" dependencies. To be specific, I suggest (profile) dependencies in place of dependencies.

That is indeed clearer. Fixed.

Why do you treat metadata.xml specially? Would it not be more natural to view the new feature as just a different way to refer to a profile including the treatment of metadata.xml (if it exists).

The same is true for the already existing import from tar archives. A metadata.xml in there is ignored. This file is only read when registering a profile.

I sometimes wished this was different: when you edit metadata.xml of a standard profile, you have to restart your instance, otherwise it has no effect. That could be something for a different PR.

Here the idea is: if you want metadata, then you should use a standard profile.
I would use this new feature to ease upgrading. Instead of a metadata.xml, I would just add an upgradeDepends for each other profile that I need. The other two items you could add in metadata.xml are version and description, both of which we don't need.

Profile ids have the form profile-package:name. This suggests a path alternative of the form path-package:path. It would allow to universally specify profiles via paths: no need to add an additional parameter to several methods, no need to treat metadata.xml specially, True, the parameter profile_id would with this extension better have the name profile_spec, but I think a documentation note of the form: a "profile id" has either the form profile-... or path-... would be sufficient to explain the a profile can be identified either via a registered profile name or a file system path.

That could be an option. I could try that.

Comment on lines 504 to +506
o 'profile_id' must be a valid ID of a registered profile;
otherwise, raise KeyError.
But if it is None, we look at the 'path' argument.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest to remove the new path parameter and to extend instead the notion of a profile id like this:

'profile_id` has either
the form 'profile-*package*:*name*' where *name* is the name of a profile registration for *package*
or the form 'path-*package*:*subpath*' where *subpath* is a path relative to the directory of *package*.

Similar suggestions for other methods.

Comment thread src/Products/GenericSetup/interfaces.py Outdated
Comment thread src/Products/GenericSetup/interfaces.py
already applied dependency profiles. The default is to apply new
profiles (of course), and upgrade outdated ones.
See 'DEFAULT_DEPENDENCY_STRATEGY' in 'tool.py'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please specify the supported integer values and what they mean.

It is best to use an absolute path, otherwise it would depend on
your working directory.
Note that metadata.xml is never read, so you cannot use dependencies.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add another place, you spoke about restricting path to a package path (for security reasons).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is in zcml. There we only accept a path within a package. This is then translated to an absolute directory. This is needed here, because you call runAllImportStepsFromProfile(profile_id=None, path='...') so the code here does not know which package the None profile belongs to.

So in Python code you could call runAllImportStepsFromProfile(profile_id=None, path="/etc") and try to do something clever with /etc/passwd in an import step. But in any import step you can just call open('/etc/passwd') anyway, so this should not raise any further security concerns.

Comment thread src/Products/GenericSetup/interfaces.py Outdated
…ependencies.

Of course we do not read profile dependencies from a metadata.xml here: we are importing just one step.
@mauritsvanrees
Copy link
Copy Markdown
Member Author

I do not like it much:

  • special treatment of metadata.xml

This is the same as how we handle archive/tar.

  • new tar support without mention in CHANGES.rst
  • insufficient documentation for new parameter dependency_strategy

These two are not new. I have only added a bit of missing documentation.

I would prefer alternatively an extended way to identify profiles: not only via registration names but also alternatively e.g. via a path. The different ways could be distinguished via prefixes.

Interesting suggestion. I might try that.

@d-maurer
Copy link
Copy Markdown
Contributor

d-maurer commented Aug 30, 2022 via email

@mauritsvanrees mauritsvanrees marked this pull request as draft March 1, 2023 10:43
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.

2 participants