Skip to content

Commit

Permalink
Merge branch 'master' into issue_591
Browse files Browse the repository at this point in the history
  • Loading branch information
dataflake committed May 9, 2019
2 parents 52f8002 + fdf9708 commit 151cea2
Show file tree
Hide file tree
Showing 12 changed files with 154 additions and 108 deletions.
7 changes: 7 additions & 0 deletions CHANGES.rst
Expand Up @@ -47,6 +47,9 @@ Fixes
Features
++++++++

- Add a flag for suppressing object events during file import
(`#42 <https://github.com/zopefoundation/Zope/issues/42>`_)

- Add a Configuration details tab to the Control_Panel

- Resurrect the Interfaces ZMI tab
Expand All @@ -62,6 +65,10 @@ Features
Other changes
+++++++++++++

- Change naming for the generated WSGI configurations to ``zope.conf`` and
``zope.ini`` to match existing documentation for Zope configurations.
(`#571 <https://github.com/zopefoundation/Zope/issues/571>`_)

- Make Zope write a PID file again under WSGI.
This makes interaction with sysadmin tools easier.
The PID file path can be set in the Zope configuration with ``pid-filename``,
Expand Down
2 changes: 1 addition & 1 deletion docs/INSTALL.rst
Expand Up @@ -152,7 +152,7 @@ include the WSGI server software egg in the ``eggs`` specification:
gunicorn
user = admin:adminpassword
http-address = 8080
wsgi = /path/to/wsgi.ini
wsgi = /path/to/zope.ini
On Python 2 you can also forego the use of WSGI and create an old-fashioned
ZServer-based installation by pulling in the ``ZServer`` egg and setting
Expand Down
10 changes: 5 additions & 5 deletions docs/operation.rst
Expand Up @@ -67,7 +67,7 @@ an existing account with non-admin privileges.
Configuring Zope
----------------

Your instance's configuration is defined in its ``etc/wsgi.conf``
Your instance's configuration is defined in its ``etc/zope.conf``
and ``etc/zope.ini`` configuration files.

When starting Zope, if you see errors indicating that an address is in
Expand All @@ -88,7 +88,7 @@ After making any changes to the configuration file, you need to restart any
running Zope server for the affected instance before changes are in effect.

For a full description of the supported sections and directives for
``wsgi.conf``, refer to the machine readable schema description file
``zope.conf``, refer to the machine readable schema description file
``https://rawgit.com/zopefoundation/Zope/master/src/Zope2/Startup/wsgischema.xml``.


Expand Down Expand Up @@ -184,7 +184,7 @@ module and console script:

.. code-block:: console
$ bin/zconsole debug etc/wsgi.conf
$ bin/zconsole debug etc/zope.conf
>>> app
<Application at >
Expand All @@ -204,7 +204,7 @@ Again in the WSGI setup the `zconsole` module and console script can be used:

.. code-block:: console
$ bin/zconsole run etc/wsgi.conf <path_to_script> <scriptarg1> ...
$ bin/zconsole run etc/zope.conf <path_to_script> <scriptarg1> ...
Adding users
Expand All @@ -216,7 +216,7 @@ this using `addzope2user` as follows:
$ bin/addzope2user user password
The script expects to find the configuration file at ``etc/wsgi.conf``.
The script expects to find the configuration file at ``etc/zope.conf``.


Running Zope (plone.recipe.zope2instance install)
Expand Down
4 changes: 2 additions & 2 deletions docs/zope4/migration/zodb.rst
Expand Up @@ -109,8 +109,8 @@ Migration example

- Create a new Zope instance using ``mkwsgiinstance``

- Update configuration in ``zope.ini`` and ``wsgi.conf`` to match previous
Zope2 instance configuration.
- Update configuration in ``zope.ini`` and ``zope.conf`` to match
previous Zope2 instance configuration.

- Run ``zodb-py3migrate-analyze Data.fs`` to determine if third party
products have serialized objects into the ZODB that would cause decoding
Expand Down
2 changes: 1 addition & 1 deletion docs/zopebook/AdvZPT.rst
Expand Up @@ -1214,7 +1214,7 @@ File system caching is activated by setting an environment variable
named ``CHAMELEON_CACHE`` to the path of a folder on the filesystem
where Chameleon can write its compiled template representation.

Look for or add a section named ``environment`` in ``etc/wsgi.conf``
Look for or add a section named ``environment`` in ``etc/zope.conf``
and add a suitable filesystem path, for example::

<environment>
Expand Down
12 changes: 8 additions & 4 deletions src/OFS/ObjectManager.py
Expand Up @@ -650,7 +650,8 @@ def manage_exportObject(
manage_importExportForm = DTMLFile('dtml/importExport', globals())

@security.protected(import_export_objects)
def manage_importObject(self, file, REQUEST=None, set_owner=1):
def manage_importObject(self, file, REQUEST=None, set_owner=1,
suppress_events=False):
"""Import an object from a file"""
dirname, file = os.path.split(file)
if dirname:
Expand All @@ -664,7 +665,8 @@ def manage_importObject(self, file, REQUEST=None, set_owner=1):
raise BadRequest('File does not exist: %s' % escape(file, True))

imported = self._importObjectFromFile(
filepath, verify=bool(REQUEST), set_owner=set_owner)
filepath, verify=bool(REQUEST), set_owner=set_owner,
suppress_events=suppress_events)
id = imported.id
if getattr(id, '__func__', None) is not None:
id = id()
Expand All @@ -678,7 +680,8 @@ def manage_importObject(self, file, REQUEST=None, set_owner=1):
update_menu=1
)

def _importObjectFromFile(self, filepath, verify=1, set_owner=1):
def _importObjectFromFile(self, filepath, verify=1, set_owner=1,
suppress_events=False):
# locate a valid connection
connection = self._p_jar
obj = self
Expand All @@ -692,7 +695,8 @@ def _importObjectFromFile(self, filepath, verify=1, set_owner=1):
id = ob.id
if getattr(id, '__func__', None) is not None:
id = id()
self._setObject(id, ob, set_owner=set_owner)
self._setObject(id, ob, set_owner=set_owner,
suppress_events=suppress_events)

# try to make ownership implicit if possible in the context
# that the object was imported into.
Expand Down
215 changes: 125 additions & 90 deletions src/OFS/dtml/importExport.dtml
Expand Up @@ -4,96 +4,131 @@

<main class="container-fluid">

<p class="form-help">
You can export Zope objects to a file in order to transfer
them to a different Zope installation. You can either choose
to download the export file to your local machine, or save it
in the <code>var</code> directory of your Zope installation
on the server.
<strong>Note:</strong>
Zope can export/import objects in a binary format (called
ZEXP). The ZEXP format is the officially supported export/import
format for moving data between <em>identical</em> Zope installations.
It is <em>not</em> a migration tool.
</p>

<form action="manage_exportObject" method="post" class="zmi-export">

<div class="form-group row">
<label for="id" class="col-sm-3 col-md-2">Export object id</label>
<div class="col-sm-9 col-md-10">
<input class="form-control" type="text" name="id" value="<dtml-if ids><dtml-var "ids[0]" html_quote></dtml-if>"/>
</div>
</div>

<div class="form-group row">
<label for="download" class="col-sm-3 col-md-2">Export to</label>
<div class="col-sm-9 col-md-10" id="download">
<div class="form-check">
<input class="form-check-input" type="radio" name="download:int" value="1" id="download_local" />
<label for="download_local" class="form-check-label">Download to local machine</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="download:int" value="0" id="download_server" checked />
<label for="download_server" class="form-check-label">Save to file on server</label>
</div>
</div>
</div>

<div class="zmi-controls">
<input class="btn btn-primary" type="submit" name="submit" value="Export" />
</div>

</form>

<hr />

<p class="form-help">
You may import Zope objects which have been previously
exported to a file, by placing the file in the &quot;import&quot;
directory of your Zope installation on the server. You should create
the &quot;import&quot; directory in the root of your Zope installation
if it does not yet exist.
<br />
Note that by default, you will become the owner of the objects
that you are importing. If you wish the imported objects to retain
their existing ownership information, select "retain existing
ownership information".
</p>

<form action="manage_importObject" method="post" class="zmi-import">


<div class="form-group row">
<label for="file" class="col-sm-3 col-md-2">Import file name</label>
<div class="col-sm-9 col-md-10">
<select class="form-control" id="file" name="file">
<dtml-in "list_imports()"
><option value="<dtml-var sequence-item>"><dtml-var sequence-item></option>
</dtml-in>
</select>
</div>
</div>

<div class="form-group row">
<label for="ownership" class="col-sm-3 col-md-2">Ownership</label>
<div class="col-sm-9 col-md-10" id="Ownership">
<div class="form-check">
<input type="radio" class="form-check-input" name="set_owner:int" value="1" id="owner_take" checked />
<label for="owner_take" class="form-check-label">Take ownership of imported objects</label>
</div>
<div class="form-check">
<input type="radio" class="form-check-input" name="set_owner:int" value="0" id="owner_retain" />
<label for="owner_retain" class="form-check-label">Retain existing ownership information</label>
</div>
</div>
</div>

<div class="zmi-controls">
<input class="btn btn-primary" type="submit" name="submit" value="Import" />
</div>

</form>
<p class="form-help">
You can export Zope objects to a file in order to transfer
them to a different Zope installation. You can either choose
to download the export file to your local machine, or save it
in the <code>var</code> directory of your Zope installation
on the server.
<strong>Note:</strong>
Zope can export/import objects in a binary format (called
ZEXP). The ZEXP format is the officially supported export/import
format for moving data between <em>identical</em> Zope installations.
It is <em>not</em> a migration tool.
</p>

<form action="manage_exportObject" method="post" class="zmi-export">

<div class="form-group row">
<label for="id" class="col-sm-3 col-md-2">Export object id</label>
<div class="col-sm-9 col-md-10">
<input class="form-control" type="text" name="id"
value="<dtml-if ids><dtml-var "ids[0]" html_quote></dtml-if>"/>
</div>
</div>

<div class="form-group row">
<label for="download" class="col-sm-3 col-md-2">Export to</label>
<div class="col-sm-9 col-md-10" id="download">
<div class="form-check">
<input class="form-check-input" type="radio" name="download:int"
value="1" id="download_local" />
<label for="download_local" class="form-check-label">
Download to local machine
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="download:int"
value="0" id="download_server" checked />
<label for="download_server" class="form-check-label">
Save to file on server
</label>
</div>
</div>
</div>

<div class="zmi-controls">
<input class="btn btn-primary" type="submit" name="submit" value="Export" />
</div>

</form>

<hr />

<p class="form-help">
You may import Zope objects which have been previously
exported to a file, by placing the file in the &quot;import&quot;
directory of your Zope installation on the server. You should create
the &quot;import&quot; directory in the root of your Zope installation
if it does not yet exist.
<br />
Note that by default, you will become the owner of the objects
that you are importing. If you wish the imported objects to retain
their existing ownership information, select "retain existing
ownership information".
<br />
Suppressing events during an import will prevent e.g. the addition of
records for imported objects to a Catalog. Only select this if you are
aware of the consequences.
</p>

<form action="manage_importObject" method="post" class="zmi-import">


<div class="form-group row">
<label for="file" class="col-sm-3 col-md-2">Import file name</label>
<div class="col-sm-9 col-md-10">
<select class="form-control" id="file" name="file">
<dtml-in "list_imports()">
<option value="<dtml-var sequence-item>">
<dtml-var sequence-item>
</option>
</dtml-in>
</select>
</div>
</div>

<div class="form-group row">
<label for="ownership" class="col-sm-3 col-md-2">Ownership</label>
<div class="col-sm-9 col-md-10" id="Ownership">
<div class="form-check">
<input type="radio" class="form-check-input" name="set_owner:int"
value="1" id="owner_take" checked />
<label for="owner_take" class="form-check-label">
Take ownership of imported objects
</label>
</div>
<div class="form-check">
<input type="radio" class="form-check-input" name="set_owner:int"
value="0" id="owner_retain" />
<label for="owner_retain" class="form-check-label">
Retain existing ownership information
</label>
</div>
</div>
</div>

<div class="form-group row">
<label for="suppress_events" class="col-sm-3 col-md-2">
Suppress events
</label>
<div class="col-sm-9 col-md-10" id="Ownership">
<div class="form-check">
<input type="checkbox" class="form-check-input"
name="suppress_events:int"
value="1" id="suppress_events" />
<label for="suppress_events" class="form-check-label">
Suppress events during import. Dangerous, see comment above.
</label>
</div>
</div>
</div>

<div class="zmi-controls">
<input class="btn btn-primary" type="submit" name="submit" value="Import" />
</div>

</form>

</main>

Expand Down
2 changes: 1 addition & 1 deletion src/Products/PageTemplates/unicodeconflictresolver.py
Expand Up @@ -48,7 +48,7 @@ def resolve(self, context, text, expression):
class Z2UnicodeEncodingConflictResolver(object):
""" This resolver tries to lookup the encoding from the
'default-zpublisher-encoding' setting in the Zope configuration
file and defaults to sys.getdefaultencoding().
file and defaults to the old ZMI encoding iso-8859-15.
"""

def __init__(self, mode='strict'):
Expand Down
2 changes: 1 addition & 1 deletion src/Zope2/Startup/tests/test_schema.py
Expand Up @@ -67,7 +67,7 @@ def load_config_text(self, text):
def test_load_config_template(self):
import Zope2.utilities
base = os.path.dirname(Zope2.utilities.__file__)
fn = os.path.join(base, "skel", "etc", "wsgi.conf.in")
fn = os.path.join(base, "skel", "etc", "zope.conf.in")
with codecs.open(fn, encoding='utf-8') as f:
text = f.read()
self.load_config_text(text)
Expand Down
4 changes: 2 additions & 2 deletions src/Zope2/utilities/finder.py
Expand Up @@ -38,10 +38,10 @@ def get_app(self, config_file=None):

def get_zope_conf(self):
# the default config file path is assumed to live in
# $instance_home/etc/wsgi.conf, and the console scripts that use this
# $instance_home/etc/zope.conf, and the console scripts that use this
# are assumed to live in $instance_home/bin; override if the
# environ contains "ZOPE_CONF".
ihome = os.path.dirname(os.path.abspath(os.path.dirname(self.cmd)))
default_config_file = os.path.join(ihome, 'etc', 'wsgi.conf')
default_config_file = os.path.join(ihome, 'etc', 'zope.conf')
zope_conf = os.environ.get('ZOPE_CONF', default_config_file)
return zope_conf
File renamed without changes.
2 changes: 1 addition & 1 deletion src/Zope2/utilities/skel/etc/zope.ini.in
@@ -1,6 +1,6 @@
[app:zope]
use = egg:Zope#main
zope_conf = %(here)s/wsgi.conf
zope_conf = %(here)s/zope.conf

[server:main]
use = egg:waitress#main
Expand Down

0 comments on commit 151cea2

Please sign in to comment.