Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
gargantext
Project
Project
Details
Activity
Releases
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
humanities
gargantext
Commits
c13ecc7f
Commit
c13ecc7f
authored
Jan 19, 2016
by
delanoe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[SESSION] removing sessions for web and api.
parent
847fce4a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
27 deletions
+5
-27
api2.py
gargantext_web/api2.py
+1
-1
api.py
rest_v1_0/api.py
+4
-26
No files found.
gargantext_web/api2.py
View file @
c13ecc7f
...
@@ -13,7 +13,7 @@ import collections
...
@@ -13,7 +13,7 @@ import collections
from
gargantext_web.views
import
move_to_trash
from
gargantext_web.views
import
move_to_trash
from
gargantext_web.db
import
*
from
gargantext_web.db
import
*
from
gargantext_web.
db
import
session
from
gargantext_web.
views
import
session
from
gargantext_web.validation
import
validate
,
ValidationException
from
gargantext_web.validation
import
validate
,
ValidationException
from
node
import
models
from
node
import
models
...
...
rest_v1_0/api.py
View file @
c13ecc7f
...
@@ -11,8 +11,11 @@ import datetime
...
@@ -11,8 +11,11 @@ import datetime
import
copy
import
copy
from
gargantext_web.views
import
move_to_trash
from
gargantext_web.views
import
move_to_trash
from
gargantext_web.db
import
get_session
,
cache
,
Node
,
NodeNgram
,
NodeNgramNgram
,
NodeNodeNgram
,
Ngram
,
Hyperdata
,
Node_Ngram
\
from
gargantext_web.db
import
cache
,
Node
,
NodeNgram
,
NodeNgramNgram
,
NodeNodeNgram
,
Ngram
,
Hyperdata
,
Node_Ngram
\
,
NodeType
,
Node_Hyperdata
,
NodeType
,
Node_Hyperdata
from
gargantext_web.views
import
session
from
gargantext_web.validation
import
validate
,
ValidationException
from
gargantext_web.validation
import
validate
,
ValidationException
from
node
import
models
from
node
import
models
...
@@ -65,7 +68,6 @@ class APIException(_APIException):
...
@@ -65,7 +68,6 @@ class APIException(_APIException):
self
.
status_code
=
code
self
.
status_code
=
code
self
.
detail
=
message
self
.
detail
=
message
session
=
get_session
()
_operators_dict
=
{
_operators_dict
=
{
"="
:
lambda
field
,
value
:
(
field
==
value
),
"="
:
lambda
field
,
value
:
(
field
==
value
),
...
@@ -97,12 +99,10 @@ def Root(request, format=None):
...
@@ -97,12 +99,10 @@ def Root(request, format=None):
'snippets'
:
reverse
(
'snippet-list'
,
request
=
request
,
format
=
format
)
'snippets'
:
reverse
(
'snippet-list'
,
request
=
request
,
format
=
format
)
})
})
session
.
remove
()
class
NodesChildrenNgrams
(
APIView
):
class
NodesChildrenNgrams
(
APIView
):
def
get
(
self
,
request
,
node_id
):
def
get
(
self
,
request
,
node_id
):
session
=
get_session
()
# query ngrams
# query ngrams
ParentNode
=
aliased
(
Node
)
ParentNode
=
aliased
(
Node
)
...
@@ -144,12 +144,10 @@ class NodesChildrenNgrams(APIView):
...
@@ -144,12 +144,10 @@ class NodesChildrenNgrams(APIView):
],
],
})
})
session
.
remove
()
class
NodesChildrenNgramsIds
(
APIView
):
class
NodesChildrenNgramsIds
(
APIView
):
def
get
(
self
,
request
,
node_id
):
def
get
(
self
,
request
,
node_id
):
session
=
get_session
()
# query ngrams
# query ngrams
ParentNode
=
aliased
(
Node
)
ParentNode
=
aliased
(
Node
)
...
@@ -190,14 +188,12 @@ class NodesChildrenNgramsIds(APIView):
...
@@ -190,14 +188,12 @@ class NodesChildrenNgramsIds(APIView):
],
],
})
})
session
.
remove
()
from
gargantext_web.db
import
get_or_create_node
from
gargantext_web.db
import
get_or_create_node
class
Ngrams
(
APIView
):
class
Ngrams
(
APIView
):
def
get
(
self
,
request
,
node_id
):
def
get
(
self
,
request
,
node_id
):
session
=
get_session
()
# query ngrams
# query ngrams
ParentNode
=
aliased
(
Node
)
ParentNode
=
aliased
(
Node
)
...
@@ -315,12 +311,10 @@ class Ngrams(APIView):
...
@@ -315,12 +311,10 @@ class Ngrams(APIView):
],
],
})
})
session
.
remove
()
class
NodesChildrenDuplicates
(
APIView
):
class
NodesChildrenDuplicates
(
APIView
):
def
_fetch_duplicates
(
self
,
request
,
node_id
,
extra_columns
=
None
,
min_count
=
1
):
def
_fetch_duplicates
(
self
,
request
,
node_id
,
extra_columns
=
None
,
min_count
=
1
):
session
=
get_session
()
# input validation
# input validation
if
extra_columns
is
None
:
if
extra_columns
is
None
:
...
@@ -361,7 +355,6 @@ class NodesChildrenDuplicates(APIView):
...
@@ -361,7 +355,6 @@ class NodesChildrenDuplicates(APIView):
# and now, return it
# and now, return it
return
duplicates_query
return
duplicates_query
session
.
remove
()
def
get
(
self
,
request
,
node_id
):
def
get
(
self
,
request
,
node_id
):
# data to be returned
# data to be returned
...
@@ -412,7 +405,6 @@ class NodesChildrenDuplicates(APIView):
...
@@ -412,7 +405,6 @@ class NodesChildrenDuplicates(APIView):
# retrieve metadata from a given list of parent node
# retrieve metadata from a given list of parent node
def
get_metadata
(
corpus_id_list
):
def
get_metadata
(
corpus_id_list
):
session
=
get_session
()
# query hyperdata keys
# query hyperdata keys
ParentNode
=
aliased
(
Node
)
ParentNode
=
aliased
(
Node
)
...
@@ -467,7 +459,6 @@ def get_metadata(corpus_id_list):
...
@@ -467,7 +459,6 @@ def get_metadata(corpus_id_list):
# give the result back
# give the result back
return
collection
return
collection
session
.
remove
()
class
ApiHyperdata
(
APIView
):
class
ApiHyperdata
(
APIView
):
...
@@ -491,7 +482,6 @@ class ApiNgrams(APIView):
...
@@ -491,7 +482,6 @@ class ApiNgrams(APIView):
# query ngrams
# query ngrams
ParentNode
=
aliased
(
Node
)
ParentNode
=
aliased
(
Node
)
session
=
get_session
()
ngrams_query
=
(
session
ngrams_query
=
(
session
.
query
(
Ngram
.
terms
,
func
.
sum
(
Node_Ngram
.
weight
)
.
label
(
'count'
))
.
query
(
Ngram
.
terms
,
func
.
sum
(
Node_Ngram
.
weight
)
.
label
(
'count'
))
.
join
(
Node_Ngram
,
Node_Ngram
.
ngram_id
==
Ngram
.
id
)
.
join
(
Node_Ngram
,
Node_Ngram
.
ngram_id
==
Ngram
.
id
)
...
@@ -533,7 +523,6 @@ class ApiNgrams(APIView):
...
@@ -533,7 +523,6 @@ class ApiNgrams(APIView):
class
NodesChildrenQueries
(
APIView
):
class
NodesChildrenQueries
(
APIView
):
def
_sql
(
self
,
input
,
node_id
):
def
_sql
(
self
,
input
,
node_id
):
session
=
get_session
()
fields
=
dict
()
fields
=
dict
()
tables
=
set
(
'nodes'
)
tables
=
set
(
'nodes'
)
hyperdata_aliases
=
dict
()
hyperdata_aliases
=
dict
()
...
@@ -616,7 +605,6 @@ class NodesChildrenQueries(APIView):
...
@@ -616,7 +605,6 @@ class NodesChildrenQueries(APIView):
else
query
[
input
[
'pagination'
][
'offset'
]:]
else
query
[
input
[
'pagination'
][
'offset'
]:]
)
)
return
output
return
output
session
.
remove
()
def
_haskell
(
self
,
input
,
node_id
):
def
_haskell
(
self
,
input
,
node_id
):
output
=
copy
.
deepcopy
(
input
)
output
=
copy
.
deepcopy
(
input
)
...
@@ -717,7 +705,6 @@ class NodesList(APIView):
...
@@ -717,7 +705,6 @@ class NodesList(APIView):
authentication_classes
=
(
SessionAuthentication
,
BasicAuthentication
)
authentication_classes
=
(
SessionAuthentication
,
BasicAuthentication
)
def
get
(
self
,
request
):
def
get
(
self
,
request
):
session
=
get_session
()
print
(
"user id : "
+
str
(
request
.
user
))
print
(
"user id : "
+
str
(
request
.
user
))
query
=
(
session
query
=
(
session
...
@@ -735,11 +722,9 @@ class NodesList(APIView):
...
@@ -735,11 +722,9 @@ class NodesList(APIView):
for
node
in
query
.
all
()
for
node
in
query
.
all
()
]})
]})
session
.
remove
()
class
Nodes
(
APIView
):
class
Nodes
(
APIView
):
def
get
(
self
,
request
,
node_id
):
def
get
(
self
,
request
,
node_id
):
session
=
get_session
()
node
=
session
.
query
(
Node
)
.
filter
(
Node
.
id
==
node_id
)
.
first
()
node
=
session
.
query
(
Node
)
.
filter
(
Node
.
id
==
node_id
)
.
first
()
if
node
is
None
:
if
node
is
None
:
...
@@ -754,7 +739,6 @@ class Nodes(APIView):
...
@@ -754,7 +739,6 @@ class Nodes(APIView):
'hyperdata'
:
node
.
hyperdata
,
'hyperdata'
:
node
.
hyperdata
,
})
})
session
.
remove
()
# deleting node by id
# deleting node by id
# currently, very dangerous.
# currently, very dangerous.
...
@@ -762,7 +746,6 @@ class Nodes(APIView):
...
@@ -762,7 +746,6 @@ class Nodes(APIView):
# for better constistency...
# for better constistency...
def
delete
(
self
,
request
,
node_id
):
def
delete
(
self
,
request
,
node_id
):
session
=
get_session
()
user
=
request
.
user
user
=
request
.
user
node
=
session
.
query
(
Node
)
.
filter
(
Node
.
id
==
node_id
)
.
first
()
node
=
session
.
query
(
Node
)
.
filter
(
Node
.
id
==
node_id
)
.
first
()
...
@@ -777,7 +760,6 @@ class Nodes(APIView):
...
@@ -777,7 +760,6 @@ class Nodes(APIView):
except
Exception
as
error
:
except
Exception
as
error
:
msgres
=
"error deleting : "
+
node_id
+
str
(
error
)
msgres
=
"error deleting : "
+
node_id
+
str
(
error
)
session
.
remove
()
class
CorpusController
:
class
CorpusController
:
@
classmethod
@
classmethod
...
@@ -786,7 +768,6 @@ class CorpusController:
...
@@ -786,7 +768,6 @@ class CorpusController:
corpus_id
=
int
(
corpus_id
)
corpus_id
=
int
(
corpus_id
)
except
:
except
:
raise
ValidationError
(
'Corpora are identified by an integer.'
,
400
)
raise
ValidationError
(
'Corpora are identified by an integer.'
,
400
)
session
=
get_session
()
corpusQuery
=
session
.
query
(
Node
)
.
filter
(
Node
.
id
==
corpus_id
)
.
first
()
corpusQuery
=
session
.
query
(
Node
)
.
filter
(
Node
.
id
==
corpus_id
)
.
first
()
# print(str(corpusQuery))
# print(str(corpusQuery))
# raise Http404("404 error.")
# raise Http404("404 error.")
...
@@ -798,7 +779,6 @@ class CorpusController:
...
@@ -798,7 +779,6 @@ class CorpusController:
# if corpus.user != request.user:
# if corpus.user != request.user:
# raise Http403("Unauthorized access.")
# raise Http403("Unauthorized access.")
return
corpus
return
corpus
session
.
remove
()
@
classmethod
@
classmethod
def
ngrams
(
cls
,
request
,
node_id
):
def
ngrams
(
cls
,
request
,
node_id
):
...
@@ -808,7 +788,6 @@ class CorpusController:
...
@@ -808,7 +788,6 @@ class CorpusController:
# build query
# build query
ParentNode
=
aliased
(
Node
)
ParentNode
=
aliased
(
Node
)
session
=
get_session
()
query
=
(
session
query
=
(
session
.
query
(
Ngram
.
terms
,
func
.
count
(
'*'
))
.
query
(
Ngram
.
terms
,
func
.
count
(
'*'
))
...
@@ -837,4 +816,3 @@ class CorpusController:
...
@@ -837,4 +816,3 @@ class CorpusController:
else
:
else
:
raise
ValidationError
(
'Unrecognized "format=
%
s", should be "csv" or "json"'
%
(
format
,
))
raise
ValidationError
(
'Unrecognized "format=
%
s", should be "csv" or "json"'
%
(
format
,
))
session
.
remove
()
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