Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
w2pext
plugin_dbui
Commits
08cd6fe9
Commit
08cd6fe9
authored
Dec 06, 2019
by
LE GAC Renaud
Browse files
Update helper to use Path in get_script_path and get_reference_paths.
parent
1412c378
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
16 deletions
+16
-16
modules/plugin_dbui/helper.py
modules/plugin_dbui/helper.py
+16
-16
No files found.
modules/plugin_dbui/helper.py
View file @
08cd6fe9
""" a series of helper functions
"""
import
os
import
re
import
subprocess
from
.constant
import
INLINE_ALERT
...
...
@@ -485,10 +483,12 @@ def get_reference_paths():
``("applications/myapp", "/myapp")``
"""
server_path
=
os
.
path
.
join
(
"applications"
,
current
.
request
.
application
)
client_path
=
os
.
path
.
join
(
os
.
path
.
sep
,
current
.
request
.
application
)
application
=
current
.
request
.
application
server_path
=
Path
(
"applications"
,
application
)
client_path
=
Path
(
"/"
,
application
)
return
(
server_path
,
client_path
)
return
(
str
(
server_path
)
,
str
(
client_path
)
)
def
get_set_field
(
field
):
...
...
@@ -541,32 +541,32 @@ def get_script_path(plugin):
Returns:
str:
the local path of the script file relative to the
application directory
.
* absolute path with respect to the application
* for example /myapp/blabla
.
"""
server_path
,
client_path
=
get_reference_paths
()
application
=
current
.
request
.
application
app_path
=
Path
(
"applications"
,
application
)
# script name specifies in the URL
if
"script"
in
current
.
request
.
vars
:
script
=
current
.
request
.
vars
.
script
if
not
script
.
endswith
(
".js"
):
script
=
"%s.js"
%
script
pdir
=
os
.
path
.
join
(
server_path
,
plugin
.
app_script_dir
)
script
=
f
"
{
script
}
.js"
if
script
not
in
os
.
listdir
(
pdir
):
raise
HTTP
(
500
,
'Request script "%s" does not exist !!!'
%
script
)
pscript
=
app_path
/
plugin
.
app_script_dir
/
script
if
not
pscript
.
exists
():
raise
HTTP
(
500
,
f
"Request script '
{
script
}
' does not exist !!!"
)
return
os
.
path
.
join
(
client_path
,
plugin
.
app_script_dir
,
script
)
return
str
(
Path
(
"/"
,
application
,
plugin
.
app_script_dir
,
script
)
)
# default script for the application
if
plugin
.
app_script
:
return
os
.
path
.
join
(
client_path
,
plugin
.
app_script
)
return
str
(
Path
(
"/"
,
application
,
plugin
.
app_script
)
)
# default script for the plugin
return
os
.
path
.
join
(
client_path
,
plugin
.
dbui_script
)
return
str
(
Path
(
"/"
,
application
,
plugin
.
dbui_script
)
)
def
get_store_id
(
name
):
...
...
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