本文整理汇总了Python中shuup.utils.importing.load函数的典型用法代码示例。如果您正苦于以下问题:Python load函数的具体用法?Python load怎么用?Python load使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了load函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_region_views
def test_region_views(rf, admin_user):
get_default_shop()
view = load("shuup_shipping_table.admin.views.region.RegionListView").as_view()
request = apply_request_middleware(rf.get("/"), user=admin_user)
response = view(request)
assert response.status_code == 200
view = load("shuup_shipping_table.admin.views.region.RegionEditView").as_view()
request = apply_request_middleware(rf.get("/"), user=admin_user)
response = view(request)
assert response.status_code == 200
view = load("shuup_shipping_table.admin.views.region.RegionDeleteView").as_view()
request = apply_request_middleware(rf.post("/"), user=admin_user)
with pytest.raises(Http404):
response = view(request, pk=1)
view = load("shuup_shipping_table.admin.views.region.RegionImportView").as_view()
request = apply_request_middleware(rf.post("/"), user=admin_user)
response = view(request)
assert response.status_code == 302
view = load("shuup_shipping_table.admin.views.region.RegionExportView").as_view()
request = apply_request_middleware(rf.get("/"), user=admin_user)
response = view(request)
assert response.status_code == 200
开发者ID:rockho-team,项目名称:shuup-shipping-table,代码行数:28,代码来源:test_admin_views.py
示例2: dispatch
def dispatch(self, request, *args, **kwargs):
module_str = "%s:%s" % (request.GET.get("module"), request.GET.get("model"))
self.return_url = reverse("shuup_admin:%s.list" % request.GET.get("return_url"))
match = resolve(self.return_url)
default_columns = load("%s:%s" % (match.func.__module__, match.func.__name__)).default_columns
self.model = load(module_str)
self.settings = ViewSettings(self.model, default_columns)
return super(ListSettingsView, self).dispatch(request, *args, **kwargs)
开发者ID:suutari,项目名称:shoop,代码行数:8,代码来源:__init__.py
示例3: test_list_view
def test_list_view(rf, class_spec):
view = load(class_spec).as_view()
request = rf.get("/", {
"jq": json.dumps({"perPage": 100, "page": 1})
})
response = view(request)
assert 200 <= response.status_code < 300
开发者ID:suutari,项目名称:shoop,代码行数:7,代码来源:test_views.py
示例4: test_tour_view
def test_tour_view(rf, admin_user):
shop = get_default_shop()
assert is_tour_complete(shop, "home", admin_user) is False
view = load("shuup.admin.views.tour:TourView").as_view()
request = apply_request_middleware(rf.post("/", data={"tourKey": "home"}), user=admin_user)
view(request)
assert is_tour_complete(shop, "home", admin_user)
开发者ID:ruqaiya,项目名称:shuup,代码行数:7,代码来源:test_views.py
示例5: _configure_basket
def _configure_basket(request):
"""
Search for some needed keys in the checkout phases storages
"""
# (src key, destination key) pair
search_keys = [
('payment_method_id', 'payment_method_id'),
('shipping_method_id', 'shipping_method_id'),
('shipping', 'shipping_address'),
('shipping_extra', 'shipping_address_extra'),
('payment', 'payment_address'),
('payment_extra', 'payment_address_extra'),
]
for phase in cached_load("SHUUP_CHECKOUT_VIEW_SPEC").phase_specs:
phase_class = load(phase)
storage = CheckoutPhaseStorage(request, phase_class.identifier)
for key, dst_key in search_keys:
value = storage.get(key)
# key found, set it to request.basket on dst_key
if value:
setattr(request.basket, dst_key, value)
开发者ID:rockho-team,项目名称:shuup-cielo,代码行数:26,代码来源:views.py
示例6: test_iframe_mode
def test_iframe_mode(rf, admin_user, extra_query_param, extra_query_value, expected_script):
get_default_shop()
view = load("shuup.admin.modules.categories.views:CategoryEditView").as_view()
request = apply_request_middleware(rf.get("/", {"mode": "iframe"}), user=admin_user)
response = view(request)
if hasattr(response, "render"):
response.render()
assert 200 <= response.status_code < 300
content = force_text(response.content)
post = extract_form_fields(BeautifulSoup(content, "lxml"))
post.update({
"base-name__en": "Name"
})
post.pop("base-image")
# save iframe mode
request = apply_request_middleware(rf.post("/", post), user=admin_user)
request.GET = request.GET.copy()
request.GET["mode"] = "iframe"
if extra_query_param:
request.GET[extra_query_param] = extra_query_value
response = view(request)
assert response.status_code == 302
client = Client()
client.login(username="admin", password="password")
response = client.get(response.url)
assert response.status_code == 200
assert expected_script in force_text(response.content)
开发者ID:ruqaiya,项目名称:shuup,代码行数:34,代码来源:test_views.py
示例7: load_setup_wizard_panes
def load_setup_wizard_panes(shop, request=None, visible_only=True):
panes = []
for pane_spec in getattr(settings, "SHUUP_SETUP_WIZARD_PANE_SPEC", []):
pane_class = load(pane_spec)
pane_inst = pane_class(request=request, object=shop)
if not visible_only or pane_inst.visible():
panes.append(pane_inst)
return panes
开发者ID:suutari,项目名称:shoop,代码行数:8,代码来源:wizard.py
示例8: test_carrier_views
def test_carrier_views(rf, admin_user):
get_default_shop()
view = load("shuup_shipping_table.admin.views.carrier.CarrierListView").as_view()
request = apply_request_middleware(rf.get("/"), user=admin_user)
response = view(request)
assert response.status_code == 200
view = load("shuup_shipping_table.admin.views.carrier.CarrierEditView").as_view()
request = apply_request_middleware(rf.get("/"), user=admin_user)
response = view(request)
assert response.status_code == 200
view = load("shuup_shipping_table.admin.views.carrier.CarrierDeleteView").as_view()
request = apply_request_middleware(rf.post("/"), user=admin_user)
with pytest.raises(Http404):
response = view(request, pk=1)
开发者ID:rockho-team,项目名称:shuup-shipping-table,代码行数:17,代码来源:test_admin_views.py
示例9: encode_enum
def encode_enum(enum_val):
enum_cls = enum_val.__class__
spec = "%s:%s" % (enum_cls.__module__, enum_cls.__name__)
try:
if load(spec) != enum_cls:
raise ImproperlyConfigured("That's not the same class!")
except ImproperlyConfigured: # Also raised by `load`
return enum_val.value # Fall back to the bare value.
return [spec, enum_val.value]
开发者ID:ruqaiya,项目名称:shuup,代码行数:9,代码来源:tagged_json.py
示例10: test_detail_view
def test_detail_view(rf, admin_user, model_and_class):
get_default_shop() # obvious prerequisite
model_func, class_spec = model_and_class
model = model_func()
view = load(class_spec).as_view()
request = apply_request_middleware(rf.get("/"), user=admin_user)
response = view(request, pk=model.pk)
if hasattr(response, "render"):
response.render()
assert 200 <= response.status_code < 300
开发者ID:gurch101,项目名称:shuup,代码行数:10,代码来源:test_views.py
示例11: get_order_identifier
def get_order_identifier(order):
if order.identifier:
raise ValueError("Order passed to get_order_identifier() already has an identifier")
order_identifier_method = settings.SHUUP_ORDER_IDENTIFIER_METHOD
if order_identifier_method == "id":
return force_text(order.id)
elif callable(order_identifier_method):
return order_identifier_method(order)
else:
getter = load(order_identifier_method, "Order identifier generator")
return getter(order)
开发者ID:NamiStudio,项目名称:shuup,代码行数:11,代码来源:_order_utils.py
示例12: _load_provide_objects
def _load_provide_objects(category):
provide_specs = _get_provide_specs_from_apps(category)
loaded_provides = _loaded_provides[category]
if set(provide_specs) != set(loaded_provides.keys()): # Changes occurred, reload provides
_uncache(category)
explanation = "Loading provides %s" % category
loaded_provides = OrderedDict()
for spec in provide_specs:
loaded_provides[spec] = load(spec, explanation)
_loaded_provides[category] = loaded_provides
return _loaded_provides.get(category, {})
开发者ID:ruqaiya,项目名称:shuup,代码行数:11,代码来源:provides.py
示例13: test_toolbar_button
def test_toolbar_button(rf, admin_user):
shop = get_default_shop()
supplier = get_default_supplier()
product = create_product("simple-test-product", shop)
order = create_order_with_product(product, supplier, 6, 6, shop=shop)
view = load("shuup.admin.modules.orders.views.OrderDetailView").as_view()
request = apply_request_middleware(rf.get("/"), user=admin_user)
response = view(request, pk=order.pk)
expected_button_class = "SimplePrintoutsToolbarButton"
toolbar = response.context_data.get("toolbar")
assert any(button.__class__.__name__ == expected_button_class for button in toolbar)
assert response.status_code == 200
开发者ID:NamiStudio,项目名称:shuup,代码行数:12,代码来源:test_printouts.py
示例14: load_mass_actions
def load_mass_actions(self):
# TODO: Make extendable through provides in near future
actions = []
for action in self.mass_actions:
obj = load(action)()
redirects = isinstance(obj, PicotableRedirectMassAction)
actions.append({
"key": obj.identifier,
"value": obj.label,
"redirects": redirects,
"redirect_url": obj.redirect_url if redirects else None
})
return actions
开发者ID:suutari-ai,项目名称:shuup,代码行数:13,代码来源:picotable.py
示例15: get_reference_number
def get_reference_number(order):
if order.reference_number:
raise ValueError("Order passed to get_reference_number() already has a reference number")
reference_number_method = settings.SHUUP_REFERENCE_NUMBER_METHOD
if reference_number_method == "unique":
return get_unique_reference_number(order)
elif reference_number_method == "running":
return get_running_reference_number(order)
elif reference_number_method == "shop_running":
return get_shop_running_reference_number(order)
elif callable(reference_number_method):
return reference_number_method(order)
else:
getter = load(reference_number_method, "Reference number generator")
return getter(order)
开发者ID:NamiStudio,项目名称:shuup,代码行数:15,代码来源:_order_utils.py
示例16: test_list_view
def test_list_view(rf, class_spec, admin_user):
get_default_shop()
view = load(class_spec).as_view()
# normal request
request = apply_request_middleware(rf.get("/"), user=admin_user)
response = view(request)
assert response.status_code == 200
# picotable request
request = apply_request_middleware(rf.get("/", {
"jq": json.dumps({"perPage": 100, "page": 1})
}), user=admin_user)
response = view(request)
assert 200 <= response.status_code < 300
开发者ID:ruqaiya,项目名称:shuup,代码行数:15,代码来源:test_views.py
示例17: _load_module
def _load_module(self):
spec = self.default_module_spec
module_identifier = self.module_identifier
if module_identifier:
impls = self.get_module_implementation_map()
if module_identifier not in impls:
raise ModuleNotFound(
"Invalid module identifier %r in %s" % (module_identifier, force_ascii(repr(self)))
)
spec = impls[module_identifier]
cls = load(spec, context_explanation="Loading module for %s" % force_ascii(repr(self)))
options = getattr(self, self.module_options_field, None) or {}
return cls(self, options)
开发者ID:NamiStudio,项目名称:shuup,代码行数:15,代码来源:interface.py
示例18: load_mass_actions
def load_mass_actions(self):
actions = []
for action in self._get_mass_actions():
obj = load(action)()
action_data = {}
extra_data = obj.get_action_info(self.request)
if extra_data and isinstance(extra_data, dict):
action_data.update(extra_data)
action_data.update({
"key": obj.identifier,
"value": obj.label
})
actions.append(action_data)
return actions
开发者ID:ruqaiya,项目名称:shuup,代码行数:16,代码来源:picotable.py
示例19: load_setup_wizard_panes
def load_setup_wizard_panes(shop, request=None, visible_only=True):
"""
Load the setup Wizard panes.
The result will be a list of valid pane instances.
:type request: HttpRequest|None
:param visible_only: whether to return only visible panes
:type visible_only: bool
"""
panes = []
for pane_spec in getattr(settings, "SHUUP_SETUP_WIZARD_PANE_SPEC", []):
pane_class = load(pane_spec)
pane_inst = pane_class(request=request, object=shop)
if pane_inst.valid() and (not visible_only or pane_inst.visible()):
panes.append(pane_inst)
return panes
开发者ID:gurch101,项目名称:shuup,代码行数:16,代码来源:wizard.py
示例20: load_setup_wizard_pane
def load_setup_wizard_pane(shop, request, pane_id):
"""
Search, load and return a valid Wizard Pane by its identifier.
:type request: HttpRequest
:param pane_id: the pane identifier
:type pane_id: str
:return: the pane instance or None
:rtype: shuup.admin.views.wizard.WizardPane|None
"""
for pane_spec in getattr(settings, "SHUUP_SETUP_WIZARD_PANE_SPEC", []):
pane_class = load(pane_spec)
pane_inst = pane_class(request=request, object=shop)
if pane_inst.identifier == pane_id and pane_inst.valid():
return pane_inst
开发者ID:gurch101,项目名称:shuup,代码行数:16,代码来源:wizard.py
注:本文中的shuup.utils.importing.load函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论