Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
cea9649b
Commit
cea9649b
authored
Dec 07, 2010
by
Hanno Schlichting
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed argument parsing for entrypoint based zopectl commands.
parent
37cf7ab4
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
9 deletions
+15
-9
doc/CHANGES.rst
doc/CHANGES.rst
+2
-0
doc/operation.rst
doc/operation.rst
+7
-5
src/Zope2/Startup/zopectl.py
src/Zope2/Startup/zopectl.py
+6
-4
No files found.
doc/CHANGES.rst
View file @
cea9649b
...
@@ -11,6 +11,8 @@ http://docs.zope.org/zope2/releases/.
...
@@ -11,6 +11,8 @@ http://docs.zope.org/zope2/releases/.
Bugs Fixed
Bugs Fixed
++++++++++
++++++++++
- Fixed argument parsing for entrypoint based zopectl commands.
- Fixed the usage of ``pstats.Stats()`` output stream. The
- Fixed the usage of ``pstats.Stats()`` output stream. The
`Control_Panel/DebugInfo/manage_profile` ZMI view was broken in Python 2.5+.
`Control_Panel/DebugInfo/manage_profile` ZMI view was broken in Python 2.5+.
...
...
doc/operation.rst
View file @
cea9649b
...
@@ -176,17 +176,19 @@ in ``setup.py``. Commands have to be put in the ``zopectl.command`` group:
...
@@ -176,17 +176,19 @@ in ``setup.py``. Commands have to be put in the ``zopectl.command`` group:
Due to an implementation detail of ``zopectl`` you can not use a minus
Due to an implementation detail of ``zopectl`` you can not use a minus
character (``-``) in the command name.
character (``-``) in the command name.
This adds a ``init_app`` command that can be used directly from the commandline::
This adds a ``init_app`` command that can be used directly from the command
line::
bin\zopectl init_app
bin\zopectl init_app
The command must be implemented as a
p
ython callable. It will be called with
The command must be implemented as a
P
ython callable. It will be called with
two parameters: the Zope2 application and a
tuple with all command
line
two parameters: the Zope2 application and a
list with all command
line
arguments. Here is a basic example:
arguments. Here is a basic example:
.. code-block:: python
.. code-block:: python
def init_application(app, args):
def init_application(app, args):
print 'Initialisating the application'
print 'Initializing the application'
Make sure the callable can be imported without side-effects, such as setting
up the database connection used by Zope 2.
src/Zope2/Startup/zopectl.py
View file @
cea9649b
...
@@ -354,8 +354,9 @@ class ZopeCmd(ZDCmd):
...
@@ -354,8 +354,9 @@ class ZopeCmd(ZDCmd):
# ['run "arg 1" "arg2"'] rather than ['run','arg 1','arg2'].
# ['run "arg 1" "arg2"'] rather than ['run','arg 1','arg2'].
# If that's the case, we'll use csv to do the parsing
# If that's the case, we'll use csv to do the parsing
# so that we can split on spaces while respecting quotes.
# so that we can split on spaces while respecting quotes.
if
len
(
self
.
options
.
args
)
==
1
:
tup
=
self
.
options
.
args
tup
=
csv
.
reader
(
self
.
options
.
args
,
delimiter
=
' '
).
next
()
if
len
(
tup
)
==
1
:
tup
=
csv
.
reader
(
tup
,
delimiter
=
' '
).
next
()
# Remove -c and add command name as sys.argv[0]
# Remove -c and add command name as sys.argv[0]
cmd
=
[
'import sys'
,
cmd
=
[
'import sys'
,
...
@@ -364,13 +365,14 @@ class ZopeCmd(ZDCmd):
...
@@ -364,13 +365,14 @@ class ZopeCmd(ZDCmd):
]
]
if
len
(
tup
)
>
1
:
if
len
(
tup
)
>
1
:
argv
=
tup
[
1
:]
argv
=
tup
[
1
:]
cmd
.
append
(
'[sys.argv.append(x) for x in %s]; '
%
argv
)
for
a
in
argv
:
cmd
.
append
(
'sys.argv.append(r
\
'
%s
\
'
)'
%
a
)
cmd
.
extend
([
cmd
.
extend
([
'import pkg_resources'
,
'import pkg_resources'
,
'import Zope2'
,
'import Zope2'
,
'func=pkg_resources.EntryPoint.parse(
\
'
%s
\
'
).load(False)'
%
entry_point
,
'func=pkg_resources.EntryPoint.parse(
\
'
%s
\
'
).load(False)'
%
entry_point
,
'app=Zope2.app()'
,
'app=Zope2.app()'
,
'func(app)'
,
'func(app
, sys.argv[1:]
)'
,
])
])
cmdline
=
self
.
get_startup_cmd
(
self
.
options
.
python
,
' ; '
.
join
(
cmd
))
cmdline
=
self
.
get_startup_cmd
(
self
.
options
.
python
,
' ; '
.
join
(
cmd
))
self
.
_exitstatus
=
os
.
system
(
cmdline
)
self
.
_exitstatus
=
os
.
system
(
cmdline
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment