mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-25 05:14:40 +01:00
allow multiple statics server and fixed few smaller bugs
This commit is contained in:
parent
a0ab0fea88
commit
082fbb3547
2 changed files with 13 additions and 19 deletions
|
|
@ -23,7 +23,9 @@ class AvalonRestApi(RestApi):
|
|||
if not project_name:
|
||||
output = {}
|
||||
for project_name in self.dbcon.tables():
|
||||
project = self.dbcon[project_name].find_one({"type": "project"})
|
||||
project = self.dbcon[project_name].find_one({
|
||||
"type": "project"
|
||||
})
|
||||
output[project_name] = project
|
||||
|
||||
return CallbackResult(data=self.result_to_json(output))
|
||||
|
|
@ -44,7 +46,7 @@ class AvalonRestApi(RestApi):
|
|||
|
||||
if not self.dbcon.exist_table(_project_name):
|
||||
abort(404, "Project \"{}\" was not found in database".format(
|
||||
project_name
|
||||
_project_name
|
||||
))
|
||||
|
||||
if not _asset:
|
||||
|
|
@ -65,7 +67,7 @@ class AvalonRestApi(RestApi):
|
|||
return asset
|
||||
|
||||
abort(404, "Asset \"{}\" with {} was not found in project {}".format(
|
||||
_asset, identificator, project_name
|
||||
_asset, identificator, _project_name
|
||||
))
|
||||
|
||||
@RestApi.route("/publish/<asset_name>", url_prefix="/premiere", methods="GET")
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import re
|
|||
import inspect
|
||||
import collections
|
||||
from .lib import RestMethods
|
||||
from queue import Queue
|
||||
|
||||
from pypeapp import Logger
|
||||
|
||||
|
|
@ -208,7 +209,7 @@ class _RestApiFactory:
|
|||
"""
|
||||
registered_objs = []
|
||||
unprocessed_routes = []
|
||||
unprocessed_statics = []
|
||||
unprocessed_statics = Queue()
|
||||
|
||||
prepared_routes = {
|
||||
method: collections.defaultdict(list) for method in RestMethods
|
||||
|
|
@ -220,16 +221,6 @@ class _RestApiFactory:
|
|||
def has_handlers(self):
|
||||
return (self.has_routes or self.prepared_statics)
|
||||
|
||||
def _process_route(self, route):
|
||||
return self.unprocessed_routes.pop(
|
||||
self.unprocessed_routes.index(route)
|
||||
)
|
||||
|
||||
def _process_statics(self, item):
|
||||
return self.unprocessed_statics.pop(
|
||||
self.unprocessed_statics.index(item)
|
||||
)
|
||||
|
||||
def register_route(
|
||||
self, path, callback, url_prefix, methods, strict_match
|
||||
):
|
||||
|
|
@ -251,7 +242,7 @@ class _RestApiFactory:
|
|||
|
||||
def register_statics(self, item):
|
||||
log.debug("Registering statics path \"{}\"".format(item))
|
||||
self.unprocessed_statics.append(item)
|
||||
self.unprocessed_statics.put(item)
|
||||
|
||||
def _prepare_route(self, route):
|
||||
"""Prepare data of registered callbacks for routes.
|
||||
|
|
@ -290,8 +281,9 @@ class _RestApiFactory:
|
|||
methods has `__self__` or are defined in <locals> (it is expeted they
|
||||
do not requise access to object)
|
||||
"""
|
||||
for url_prefix, dir_path in self.unprocessed_statics:
|
||||
self._process_statics((url_prefix, dir_path))
|
||||
|
||||
while not self.unprocessed_statics.empty():
|
||||
url_prefix, dir_path = self.unprocessed_statics.get()
|
||||
dir_path = os.path.normpath(dir_path)
|
||||
if not os.path.exists(dir_path):
|
||||
log.warning(
|
||||
|
|
@ -314,7 +306,7 @@ class _RestApiFactory:
|
|||
if not method.restapi:
|
||||
continue
|
||||
|
||||
for route in self.unprocessed_routes:
|
||||
for route in list(self.unprocessed_routes):
|
||||
callback = route["callback"]
|
||||
if not (
|
||||
callback.__qualname__ == method.__qualname__ and
|
||||
|
|
@ -330,7 +322,7 @@ class _RestApiFactory:
|
|||
self._prepare_route(route)
|
||||
break
|
||||
|
||||
for route in self.unprocessed_routes:
|
||||
for route in list(self.unprocessed_routes):
|
||||
callback = route["callback"]
|
||||
is_class_method = len(callback.__qualname__.split(".")) != 1
|
||||
if is_class_method:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue