general: always push webservice/datasource/script in context (#37341)
This commit is contained in:
parent
74b430284b
commit
b9b53aac9a
|
@ -336,7 +336,6 @@ def test_data_source_substitution_variables():
|
|||
data_source.data_source = {'type': 'formula', 'value': repr(['un', 'deux'])}
|
||||
data_source.store()
|
||||
|
||||
pub.substitutions.feed(NamedDataSource)
|
||||
context = pub.substitutions.get_context_variables()
|
||||
assert context.get('data_source').foobar == [
|
||||
{'id': 'un', 'text': 'un'}, {'id': 'deux', 'text': 'deux'}]
|
||||
|
|
|
@ -141,7 +141,6 @@ def test_parse_isotime():
|
|||
def test_script_substitution_variable():
|
||||
pub = create_temporary_pub()
|
||||
pub.substitutions.feed(pub)
|
||||
pub.substitutions.feed(Script)
|
||||
variables = pub.substitutions.get_context_variables()
|
||||
with pytest.raises(AttributeError):
|
||||
assert variables['script'].hello_world()
|
||||
|
|
|
@ -60,7 +60,6 @@ def test_webservice_substitution_variable(http_requests, pub):
|
|||
wscall.store()
|
||||
assert wscall.slug == 'hello_world'
|
||||
|
||||
pub.substitutions.feed(NamedWsCall)
|
||||
variables = pub.substitutions.get_context_variables()
|
||||
assert variables['webservice'].hello_world == {'foo': 'bar'}
|
||||
|
||||
|
@ -121,7 +120,6 @@ def test_wscall_ezt(http_requests, pub):
|
|||
wscall.store()
|
||||
assert wscall.slug == 'hello_world'
|
||||
|
||||
pub.substitutions.feed(NamedWsCall)
|
||||
variables = pub.substitutions.get_context_variables()
|
||||
|
||||
template = Template('<p>{{ webservice.hello_world.foo }}</p>')
|
||||
|
|
|
@ -37,7 +37,13 @@ class Substitutions(object):
|
|||
_forced_mode = None
|
||||
|
||||
def __init__(self):
|
||||
self.sources = []
|
||||
self.set_empty()
|
||||
|
||||
def set_empty(self):
|
||||
from wcs.data_sources import NamedDataSource
|
||||
from wcs.wscalls import NamedWsCall
|
||||
from wcs.scripts import Script
|
||||
self.sources = [NamedDataSource, NamedWsCall, Script]
|
||||
|
||||
@classmethod
|
||||
def register(cls, varname, category=None, comment=None):
|
||||
|
@ -57,7 +63,7 @@ class Substitutions(object):
|
|||
|
||||
@invalidate_substitution_cache
|
||||
def reset(self):
|
||||
self.sources = []
|
||||
self.set_empty()
|
||||
|
||||
def feed(self, source):
|
||||
if source is None:
|
||||
|
|
|
@ -40,13 +40,10 @@ from .qommon.afterjobs import AfterJobStatusDirectory
|
|||
|
||||
from .categories import Category
|
||||
from .formdef import FormDef
|
||||
from .data_sources import NamedDataSource
|
||||
from .wscalls import NamedWsCall
|
||||
from .api import ApiDirectory
|
||||
from .myspace import MyspaceDirectory
|
||||
from .forms.preview import PreviewDirectory
|
||||
from .forms.actions import ActionsDirectory
|
||||
from .scripts import Script
|
||||
|
||||
from . import portfolio
|
||||
|
||||
|
@ -315,9 +312,6 @@ class RootDirectory(Directory):
|
|||
def feed_substitution_parts(self):
|
||||
get_publisher().substitutions.feed(get_session())
|
||||
get_publisher().substitutions.feed(get_request().user)
|
||||
get_publisher().substitutions.feed(NamedDataSource)
|
||||
get_publisher().substitutions.feed(NamedWsCall)
|
||||
get_publisher().substitutions.feed(Script)
|
||||
|
||||
def _q_traverse(self, path):
|
||||
self.feed_substitution_parts()
|
||||
|
|
Loading…
Reference in New Issue