Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Coopdevs OCB mirror
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Coopdevs
Odoo
Coopdevs OCB mirror
Commits
0ea465e8
Commit
0ea465e8
authored
11 years ago
by
Xavier Morel
Browse files
Options
Downloads
Patches
Plain Diff
[IMP] simplify howto wording, add modules directory (output) to scaffold
parent
68eb0983
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
doc/howto/howto_website.rst
+8
-9
8 additions, 9 deletions
doc/howto/howto_website.rst
openerpcommand/scaffold.py
+12
-2
12 additions, 2 deletions
openerpcommand/scaffold.py
with
20 additions
and
11 deletions
doc/howto/howto_website.rst
+
8
−
9
View file @
0ea465e8
...
@@ -22,9 +22,11 @@ In OpenERP, doing things takes the form of creating modules, and these modules
...
@@ -22,9 +22,11 @@ In OpenERP, doing things takes the form of creating modules, and these modules
customize the behavior of the OpenERP installation. The first step is thus to
customize the behavior of the OpenERP installation. The first step is thus to
create a module:
create a module:
..
c
od
e
::
shell-session
..
t
od
o
::
output directory probably shouldn't be ``.``
> oe scaffold Academy
.. code-block:: console
$ oe scaffold Academy .
.. patch::
.. patch::
:hidden:
:hidden:
...
@@ -44,10 +46,8 @@ Now start your OpenERP server and install your module in it, open a web
...
@@ -44,10 +46,8 @@ Now start your OpenERP server and install your module in it, open a web
browser and navigate to http://localhost:8069. A page should appear with just
browser and navigate to http://localhost:8069. A page should appear with just
the words "Hello, world!" on it.
the words "Hello, world!" on it.
The default response type is HTML (although we only sent some text, browsers
Let's prettify things a bit: instead of returning just a bit of text,
are pretty good at finding ways to turn stuff into things they can
we can return a page, and use a tool like bootstrap_ to get a
display). Let's prettify things a bit: instead of returning just a bit of
text, we can return a page, and use a tool/library like bootstrap_ to get a
nicer rendering than the default.
nicer rendering than the default.
Go to :file:`academy/controllers/my_controller.py` and change the string
Go to :file:`academy/controllers/my_controller.py` and change the string
...
@@ -66,10 +66,9 @@ Data input: URL and query
...
@@ -66,10 +66,9 @@ Data input: URL and query
=========================
=========================
Being able to build a static page in code is nice, but makes for limited
Being able to build a static page in code is nice, but makes for limited
usefulness (you could do that with static files in the first place, after
usefulness (you could do that with static files in the first place).
all).
But y
ou can also create controllers which use data provided in the access URL,
Y
ou can also create controllers which use data provided in the access URL,
for instance so you have a single controller generating multiple pages. Any
for instance so you have a single controller generating multiple pages. Any
query parameter (``?name=value``) is passed as a parameter to the controller
query parameter (``?name=value``) is passed as a parameter to the controller
function, and is a string.
function, and is a string.
...
...
This diff is collapsed.
Click to expand it.
openerpcommand/scaffold.py
+
12
−
2
View file @
0ea465e8
...
@@ -15,10 +15,10 @@ def run(args):
...
@@ -15,10 +15,10 @@ def run(args):
env
=
jinja2
.
Environment
(
loader
=
jinja2
.
PackageLoader
(
env
=
jinja2
.
Environment
(
loader
=
jinja2
.
PackageLoader
(
'
openerpcommand
'
,
'
templates
'
))
'
openerpcommand
'
,
'
templates
'
))
env
.
filters
[
'
snake
'
]
=
snake
env
.
filters
[
'
snake
'
]
=
snake
assert
args
.
module
args
.
dependency
=
'
web
'
if
args
.
controller
else
'
base
'
args
.
dependency
=
'
web
'
if
args
.
controller
else
'
base
'
module
=
functools
.
partial
(
os
.
path
.
join
,
snake
(
args
.
module
))
module
=
functools
.
partial
(
os
.
path
.
join
,
args
.
modules_dir
,
snake
(
args
.
module
))
if
os
.
path
.
exists
(
module
()):
if
os
.
path
.
exists
(
module
()):
message
=
"
The path `%s` already exists.
"
%
module
()
message
=
"
The path `%s` already exists.
"
%
module
()
...
@@ -48,6 +48,8 @@ def add_parser(subparsers):
...
@@ -48,6 +48,8 @@ def add_parser(subparsers):
description
=
'
Generate an OpenERP module skeleton.
'
)
description
=
'
Generate an OpenERP module skeleton.
'
)
parser
.
add_argument
(
'
module
'
,
metavar
=
'
MODULE
'
,
parser
.
add_argument
(
'
module
'
,
metavar
=
'
MODULE
'
,
help
=
'
the name of the generated module
'
)
help
=
'
the name of the generated module
'
)
parser
.
add_argument
(
'
modules_dir
'
,
metavar
=
'
DIRECTORY
'
,
type
=
directory
,
help
=
"
Modules directory in which the new module should be generated
"
)
controller
=
parser
.
add_mutually_exclusive_group
()
controller
=
parser
.
add_mutually_exclusive_group
()
controller
.
add_argument
(
'
--controller
'
,
type
=
identifier
,
controller
.
add_argument
(
'
--controller
'
,
type
=
identifier
,
...
@@ -107,6 +109,14 @@ def identifier(s):
...
@@ -107,6 +109,14 @@ def identifier(s):
die
(
"
%s is not a valid Python identifier
"
%
s
)
die
(
"
%s is not a valid Python identifier
"
%
s
)
return
s
return
s
def
directory
(
p
):
expanded
=
os
.
path
.
abspath
(
os
.
path
.
expanduser
(
os
.
path
.
expandvars
(
p
)))
if
not
os
.
path
.
isdir
(
expanded
):
die
(
"
Directory %s does not seem to exist
"
%
p
)
return
expanded
def
die
(
message
,
code
=
1
):
def
die
(
message
,
code
=
1
):
print
>>
sys
.
stderr
,
message
print
>>
sys
.
stderr
,
message
sys
.
exit
(
code
)
sys
.
exit
(
code
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment