Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
Penguidom
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
domotika
Penguidom
Commits
089b1e15
Commit
089b1e15
authored
Jan 11, 2018
by
Franco (nextime) Lanza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Web gui organization
parent
da92a8ad
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
79 deletions
+8
-79
web.py
penguidom/web/web.py
+8
-79
No files found.
penguidom/web/web.py
View file @
089b1e15
...
@@ -88,6 +88,7 @@ class RootPage(rend.Page):
...
@@ -88,6 +88,7 @@ class RootPage(rend.Page):
self
.
avatarId
=
avatarId
self
.
avatarId
=
avatarId
self
.
putChild
(
'favicon.ico'
,
static
.
File
(
curdir
+
'/Web/resources/img/favicon.ico'
))
self
.
putChild
(
'favicon.ico'
,
static
.
File
(
curdir
+
'/Web/resources/img/favicon.ico'
))
self
.
putChild
(
'crossdomain.xml'
,
static
.
File
(
curdir
+
'/Web/resources/xml/crossdomain.xml'
))
self
.
putChild
(
'crossdomain.xml'
,
static
.
File
(
curdir
+
'/Web/resources/xml/crossdomain.xml'
))
self
.
putChild
(
'sockjs.min.js'
,
static
.
File
(
curdir
+
'/Web/resources/js/sockjs.min.js'
))
def
renderHTML
(
self
,
ctx
):
def
renderHTML
(
self
,
ctx
):
request
=
inevow
.
IRequest
(
ctx
)
request
=
inevow
.
IRequest
(
ctx
)
...
@@ -103,11 +104,9 @@ class RootPage(rend.Page):
...
@@ -103,11 +104,9 @@ class RootPage(rend.Page):
def
child_rest
(
self
,
ctx
):
def
child_rest
(
self
,
ctx
):
if
str
(
self
.
core
.
configGet
(
'web'
,
'enablerestgui'
))
.
lower
()
in
[
'yes'
,
'1'
,
'y'
,
'true'
]:
self
.
rest
=
rest
.
RestPages
()
self
.
rest
=
rest
.
RestPages
()
self
.
rest
.
core
=
self
.
core
self
.
rest
.
core
=
self
.
core
return
self
.
rest
return
self
.
rest
return
self
.
childFactory
(
ctx
,
'rest'
)
def
child_rawplugin
(
self
,
ctx
):
def
child_rawplugin
(
self
,
ctx
):
request
=
inevow
.
IRequest
(
ctx
)
request
=
inevow
.
IRequest
(
ctx
)
...
@@ -134,71 +133,9 @@ class RootPage(rend.Page):
...
@@ -134,71 +133,9 @@ class RootPage(rend.Page):
log
.
debug
(
"no plugin name in request"
)
log
.
debug
(
"no plugin name in request"
)
return
self
.
childFactory
(
ctx
,
'rawplugin'
)
return
self
.
childFactory
(
ctx
,
'rawplugin'
)
def
_addPermissions
(
self
,
ctx
,
name
,
session
,
request
):
def
addPerms
(
dbres
,
ctx
,
name
,
session
,
request
):
try
:
log
.
info
(
dbres
)
if
dbres
and
len
(
dbres
)
>
0
:
session
.
dmpermissions
[
request
.
path
]
=
dbres
[
0
][
0
]
if
neededPermission
(
request
.
method
)
in
session
.
dmpermissions
[
request
.
path
]:
log
.
info
(
"PERMISSION DB OK, USER: "
+
session
.
mind
.
perms
.
username
+
" SESSION: "
+
str
(
session
.
uid
))
#+" ARGS: "+str(request.args)+" REQ "+str(request))
self
.
core
.
updateSession
(
session
.
uid
,
session
,
self
)
return
rend
.
Page
.
locateChild
(
self
,
ctx
,
name
)
except
:
try
:
log
.
info
(
"Error getting permission from DB USER: "
+
session
.
mind
.
perms
.
username
+
" SESSION: "
+
str
(
session
.
uid
)
+
" ARGS: "
+
str
(
request
.
args
)
+
" REQ "
+
str
(
request
))
except
:
log
.
info
(
"Error getting permission from DB USER: GUEST SESSION: "
+
str
(
session
.
uid
)
+
" ARGS: "
+
str
(
request
.
args
)
+
" REQ "
+
str
(
request
))
try
:
log
.
info
(
"PERMISSION DB DENIED, USER: "
+
session
.
mind
.
perms
.
username
+
" SESSION: "
+
str
(
session
.
uid
)
+
" ARGS: "
+
str
(
request
.
args
)
+
" REQ "
+
str
(
request
))
except
:
log
.
info
(
"PERMISSION DB DENIED, USER: GUEST SESSION: "
+
str
(
session
.
uid
)
+
" ARGS: "
+
str
(
request
.
args
)
+
" REQ "
+
str
(
request
))
return
permissionDenied
(),
()
if
not
'dmpermissions'
in
dir
(
session
):
session
.
dmpermissions
=
{}
if
not
request
.
path
in
session
.
dmpermissions
.
keys
():
session
.
dmpermissions
[
request
.
path
]
=
'none'
try
:
log
.
info
(
"SESS: "
+
str
(
session
.
uid
)
+
" MIND: "
+
str
(
session
.
mind
.
perms
)
+
" DMPERMS "
+
str
(
session
.
dmpermissions
))
return
self
.
core
.
getPermissionForPath
(
session
.
mind
.
perms
.
username
,
request
.
path
)
.
addCallback
(
addPerms
,
ctx
,
name
,
session
,
request
)
except
:
log
.
info
(
"USERS HAS NO MIND??? "
+
str
(
request
.
path
)
+
" "
+
str
(
session
.
uid
)
+
" "
+
str
(
request
.
args
)
+
" REQ "
+
str
(
request
)
+
" "
+
str
(
session
.
dmpermissions
))
if
'username'
in
session
.
dmpermissions
.
keys
():
log
.
debug
(
"BUT IT HAS DMPERMISSION... "
+
str
(
session
.
dmpermissions
))
return
self
.
core
.
getPermissionForPath
(
session
.
dmpermissions
[
'username'
],
request
.
path
)
.
addCallback
(
addPerms
,
ctx
,
name
,
session
,
request
)
else
:
log
.
debug
(
"ALSO NO USERNAME IN DMPERMISSION "
+
str
(
session
.
uid
))
return
self
.
core
.
getPermissionForPath
(
'guest'
,
request
.
path
)
.
addCallback
(
addPerms
,
ctx
,
name
,
session
,
request
)
def
locateChild
(
self
,
ctx
,
name
):
def
locateChild
(
self
,
ctx
,
name
):
session
=
inevow
.
ISession
(
ctx
)
return
rend
.
Page
.
locateChild
(
self
,
ctx
,
name
)
request
=
inevow
.
IRequest
(
ctx
)
try
:
uname
=
session
.
mind
.
perms
.
username
except
:
uname
=
'guest'
if
not
'sse'
in
dir
(
session
):
session
.
sse
=
False
if
not
'dmpermissions'
in
dir
(
session
):
session
.
dmpermissions
=
{}
if
request
.
path
in
WEB_SYSTEM_PATHS
:
log
.
info
(
"WEB_SYSTEM_PATH: USER: "
+
uname
+
" SESSION: "
+
str
(
session
.
uid
))
#+" ARGS: "+str(request.args)+" REQ "+str(request))
return
rend
.
Page
.
locateChild
(
self
,
ctx
,
name
)
if
request
.
path
in
session
.
dmpermissions
.
keys
():
if
neededPermission
(
request
.
method
)
in
session
.
dmpermissions
[
request
.
path
]:
log
.
debug
(
"PERMISSION OK, SESSION: "
+
str
(
session
.
uid
))
#+" ARGS: "+str(request.args)+" REQ "+str(request))
self
.
core
.
updateSession
(
session
.
uid
,
session
,
self
)
return
rend
.
Page
.
locateChild
(
self
,
ctx
,
name
)
else
:
return
self
.
_addPermissions
(
ctx
,
name
,
session
,
request
)
log
.
debug
(
"PERMISSION DENIED, SESSION: "
+
str
(
session
.
uid
)
+
" ARGS: "
+
str
(
request
.
args
)
+
" REQ "
+
str
(
request
))
return
permissionDenied
(),
()
def
child_
(
self
,
ctx
):
def
child_
(
self
,
ctx
):
...
@@ -206,22 +143,14 @@ class RootPage(rend.Page):
...
@@ -206,22 +143,14 @@ class RootPage(rend.Page):
Redirecting...
Redirecting...
"""
"""
request
=
inevow
.
IRequest
(
ctx
)
request
=
inevow
.
IRequest
(
ctx
)
host
=
request
.
getHeader
(
'host'
)
log
.
debug
(
"HOST CALLED: "
+
str
(
host
))
request
.
setHeader
(
'Location'
,
'gui/'
);
if
self
.
logged
:
if
(
len
(
self
.
perms
.
homepath
))
>
0
:
request
.
setHeader
(
'Location'
,
self
.
perms
.
homepath
);
else
:
request
.
setHeader
(
'Location'
,
self
.
core
.
configGet
(
'web'
,
'defaultpath'
))
else
:
request
.
setHeader
(
'Location'
,
self
.
core
.
configGet
(
'web'
,
'defaultpath'
))
request
.
setResponseCode
(
302
)
request
.
setResponseCode
(
302
)
return
html
return
html
def
childFactory
(
self
,
ctx
,
name
):
def
childFactory
(
self
,
ctx
,
name
):
request
=
inevow
.
IRequest
(
ctx
)
request
=
inevow
.
IRequest
(
ctx
)
host
=
request
.
getHeader
(
'host'
)
log
.
debug
(
"HOST CALLED: "
+
str
(
host
))
log
.
debug
(
"No child found (
%
s)"
%
name
)
log
.
debug
(
"No child found (
%
s)"
%
name
)
return
permissionDenied
()
return
permissionDenied
()
...
...
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