shuup.core package

Subpackages

Submodules

shuup.core.error_handling module

class shuup.core.error_handling.ErrorPageHandler[source]

Bases: object

A base class for error pages handling.

classmethod can_handle_error(request, error_status)[source]

Returns whether this object can handle the error :rtype: bool

classmethod handle_error(request, error_status)[source]

Returns a response for the given request and error status :rtype: django.http.HttpResponse

shuup.core.error_handling.make_error_view(error_status)[source]

A factory of error views which tries to find a compatible error handler If not handler can do the job, use the Django’s default or a blank response

shuup.core.error_handling.install_error_handlers()[source]

Install custom error handlers. Error handlers to be added are for errors 400, 403, 404, and 500.

shuup.core.excs module

exception shuup.core.excs.ImmutabilityError[source]

Bases: ValueError

exception shuup.core.excs.NoShippingAddressException[source]

Bases: Exception

exception shuup.core.excs.NoProductsToShipException[source]

Bases: Exception

exception shuup.core.excs.NoPaymentToCreateException[source]

Bases: Exception

exception shuup.core.excs.NoRefundToCreateException[source]

Bases: Exception

exception shuup.core.excs.RefundExceedsAmountException[source]

Bases: Exception

exception shuup.core.excs.InvalidRefundAmountException[source]

Bases: Exception

exception shuup.core.excs.MissingSettingException[source]

Bases: Exception

exception shuup.core.excs.ProductNotOrderableProblem(message, title=None)[source]

Bases: shuup.utils.excs.Problem

exception shuup.core.excs.ProductNotVisibleProblem(message, title=None)[source]

Bases: shuup.utils.excs.Problem

exception shuup.core.excs.ImpossibleProductModeException(message, code=None)[source]

Bases: ValueError

shuup.core.middleware module

class shuup.core.middleware.ExceptionMiddleware[source]

Bases: object

process_exception(request, exception)[source]

shuup.core.settings module

shuup.core.settings.SHUUP_HOME_CURRENCY = 'EUR'

The home currency for the Shuup installation. All monetary values are implicitly in this currency unless somehow otherwise specified.

shuup.core.settings.SHUUP_ADDRESS_HOME_COUNTRY = None

The home country code (ISO 3166-1 alpha 2) for the Shuup installation. Among other things, addresses that would be printed with this country visible are printed with no country.

shuup.core.settings.SHUUP_ALLOW_ANONYMOUS_ORDERS = True

Whether or not anonymous orders (without a creator user) are allowed.

shuup.core.settings.SHUUP_ORDER_IDENTIFIER_METHOD = 'id'

Which method is used to calculate order identifiers (“order numbers”). May be either the string “id”, a callable or a spec string pointing to a callable that must return a string given an order.

shuup.core.settings.SHUUP_REFERENCE_NUMBER_METHOD = 'unique'

Which method is used by default to calculate order reference numbers.

May be a spec string pointing to a callable that must return a string given an Order, or one of the following built-in generators.

unique
Unique reference number based on time and the order ID. The reference number has the Finnish bank reference check digit appended, making the reference number valid for Finnish bank transfers.
running
Ascending reference number. The length of the reference number will be SHUUP_REFERENCE_NUMBER_LENGTH + 1 (for the check digit described below). SHUUP_REFERENCE_NUMBER_PREFIX is prepended, if set. The reference number has the Finnish bank reference check digit appended, making the reference number valid for Finnish bank transfers.
shop_running
As running, but with the shop ID prepended.
shuup.core.settings.SHUUP_REFERENCE_NUMBER_LENGTH = 17

The default length of reference numbers generated by certain reference number generators.

shuup.core.settings.SHUUP_REFERENCE_NUMBER_PREFIX = ''

An arbitrary (numeric) default prefix for certain reference number generators.

shuup.core.settings.SHUUP_PRICING_MODULE = 'default_pricing'

The identifier of the pricing module to use for pricing products.

Determines how product prices are calculated. See shuup.core.pricing for details.

shuup.core.settings.SHUUP_DISCOUNT_MODULES = []

List of identifiers of discount modules to use.

Each discount module may change the price of a product. See shuup.core.pricing.DiscountModule for details.

shuup.core.settings.SHUUP_ORDER_SOURCE_MODIFIER_MODULES = []

List of identifiers of order source modifier modules.

See shuup.core.order_creator.OrderSourceModifierModule for details.

shuup.core.settings.SHUUP_TAX_MODULE = 'default_tax'

The identifier of the tax module to use for determining taxes of products and order lines.

Determines taxing rules for products, shipping/payment methods and other order lines. See shuup.core.taxing for details.

shuup.core.settings.SHUUP_ENABLE_ATTRIBUTES = True

Whether product attributes are enabled. For installations not requiring attributes, disabling this may confer a small performance increase.

shuup.core.settings.SHUUP_ENABLE_MULTIPLE_SHOPS = False

Whether multiple shops are expected to be enabled in this installation. Enabling or disabling this flag does not make it (im)possible to set up multiple shops, but having it disabled may confer a small performance increase.

shuup.core.settings.SHUUP_ENABLE_MULTIPLE_SUPPLIERS = False

Whether multiple suppliers are enabled in this installation. Enabling this flag prevents supplier creation from admin.

shuup.core.settings.SHUUP_ORDER_LABELS = [('default', 'Default')]

A list of order labels (2-tuples of internal identifier / visible name).

Order labels serve as a simple taxonomy layer for easy “tagging” of orders even within a single Shop. For instance, an installation could define "default" and "internal" order labels, which are then usable in reports, admin filtering, etc.

shuup.core.settings.SHUUP_DEFAULT_ORDER_LABEL = 'default'

The order label (see SHUUP_ORDER_LABELS) to apply to orders by default. This should naturally be one of the keys in SHUUP_ORDER_LABELS.

shuup.core.settings.SHUUP_ORDER_KNOWN_PAYMENT_DATA_KEYS = []

A list of “known keys” within the Order.payment_data property bag.

The format of this setting is a list of 2-tuples of dict key / visible name, for example [("ssn", "Social Security Number")].

For installations where customizations may save some human-readable, possibly important information in payment_data, this setting may be used to make this data easily visible in the administration backend.

shuup.core.settings.SHUUP_ORDER_KNOWN_SHIPPING_DATA_KEYS = []

A list of “known keys” within the Order.shipping_data property bag.

The format of this setting is a list of 2-tuples of dict key / visible name, for example [("shipping_instruction", "Special Shipping Instructions")].

For installations where customizations may save some human-readable, possibly important information in shipping_data, this setting may be used to make this data easily visible in the administration backend.

shuup.core.settings.SHUUP_ORDER_KNOWN_EXTRA_DATA_KEYS = []

A list of “known keys” within the Order.extra_data property bag.

The format of this setting is a list of 2-tuples of dict key / visible name, for example [("wrapping_color", "Wrapping Paper Color")].

For installations where customizations may save some human-readable, possibly important information in extra_data, this setting may be used to make this data easily visible in the administration backend.

shuup.core.settings.SHUUP_TELEMETRY_ENABLED = True

A flag to enable/disable the telemetry system

shuup.core.settings.SHUUP_TELEMETRY_HOST_URL = 'https://telemetry.shuup.com'

The host URL for Shuup’s telemetry (statistics) system

shuup.core.settings.SHUUP_TELEMETRY_URL = 'https://telemetry.shuup.com/collect/'

The submission URL for Shuup’s telemetry (statistics) system

shuup.core.settings.SHUUP_SUPPORT_ID_URL = 'https://telemetry.shuup.com/support-id'

The URL to fetch the Shuup installation support id

shuup.core.settings.SHUUP_DEFAULT_CACHE_DURATION = 1800

Default cache duration for various caches in seconds

shuup.core.settings.SHUUP_CACHE_DURATIONS = {}

Overrides for default cache durations by key namespace. These override possible defaults in shuup.core.cache.impl.DEFAULT_CACHE_DURATIONS.

shuup.core.settings.SHUUP_CALCULATE_TAXES_AUTOMATICALLY_IF_POSSIBLE = True

Whether taxes should be calculated automatically in TaxModule

shuup.core.settings.SHUUP_ADDRESS_FORMATTER_SPEC = 'shuup.core.utils.formatters:DefaultAddressFormatter'

Spec which defines an address formatter used to format output string of an Address model instances

shuup.core.settings.SHUUP_ADDRESS_MODEL_FORM = 'shuup.core.utils.forms.MutableAddressForm'

Spec which defines an default address model form

shuup.core.settings.SHUUP_ADDRESS_FIELD_PROPERTIES = {}

A dictionary defining properties to override the default field properties of the checkout address form and also the Address API.

System Message: ERROR/3 (/home/docs/checkouts/readthedocs.org/user_builds/shuup/checkouts/v2.0.0/shuup/core/settings.py:docstring of shuup.core.settings.SHUUP_ADDRESS_FIELD_PROPERTIES, line 3)

Unexpected indentation.
Should map the field name (as a string) to a dictionary containing the overriding Django form field properties, as in the following

System Message: WARNING/2 (/home/docs/checkouts/readthedocs.org/user_builds/shuup/checkouts/v2.0.0/shuup/core/settings.py:docstring of shuup.core.settings.SHUUP_ADDRESS_FIELD_PROPERTIES, line 5)

Block quote ends without a blank line; unexpected unindent.

example which makes the postal code a required field:

SHUUP_ADDRESS_FIELD_PROPERTIES = {
“postal_code”: {“required”: True}

System Message: WARNING/2 (/home/docs/checkouts/readthedocs.org/user_builds/shuup/checkouts/v2.0.0/shuup/core/settings.py:docstring of shuup.core.settings.SHUUP_ADDRESS_FIELD_PROPERTIES, line 9)

Definition list ends without a blank line; unexpected unindent.

}

Some of the Django form field properties will not affect the Address API. The valid set of properties are those defined by the Serializer fields core arguments like read_only, required, allow_null, etc. See the Django Rest Framework documentation for more properties.

It should be noted, however, that overriding some settings (such as making a required field non-required) could create other validation issues.

shuup.core.settings.SHUUP_MAX_DAYS_IN_TELEMETRY = 180

Indicates maximum days for daily data included to one telemetry request

shuup.core.settings.SHUUP_AUTO_SHOP_PRODUCT_CATEGORIES = True

Spec which defines if shop product categories will be automatically populated on save or when the shop_product categories change.

Example A: shop_product.categories = [] shop_product.primary_category = “A” shop_product.save() => “A” will be added to categories

Example B: shop_product.primary_category = None shop_product.categories = [“A”, “B”] => “A” will be made the shop_product.primary_category

shuup.core.settings.SHUUP_ERROR_PAGE_HANDLERS_SPEC = []

Spec which defines a list of handlers of page errors overwriting Django’s default error handlers configured in urls.py (if some).

Shuup will iterate over all handlers in order to determinate if some can handle the error. In case of no handler can do the job, a blank response will be returned.

A handler must be a subclass of shuup.core.error_handling.ErrorPageHandler.

If no handler is set (blank), Shuup will use default Django’s handlers.

shuup.core.signals module

shuup.core.telemetry module

shuup.core.telemetry.safe_json(data_dict, indent=None)[source]
shuup.core.telemetry.get_installation_key()[source]

Get the unique installation ID for this Shuup instance.

If one doesn’t exist, it’s generated and saved at this point.

Returns:Installation key string
Return type:str
shuup.core.telemetry.is_opt_out()[source]
shuup.core.telemetry.is_in_grace_period()[source]

Return True if the telemetry module is within the 24-hours-from-installation grace period where no stats are sent. This is to “safely” allow opting out of telemetry without leaving a trace.

Returns:Graceness flag.
Return type:bool
shuup.core.telemetry.is_telemetry_enabled()[source]
shuup.core.telemetry.set_opt_out(flag)[source]

Set whether this installation is opted-out from telemetry submissions.

Parameters:flag (bool) – Opt-out flag. True for opt-out, false for opt-in (default)
Returns:New flag state
Return type:bool
shuup.core.telemetry.get_last_submission_time()[source]
shuup.core.telemetry.get_last_submission_data()[source]
shuup.core.telemetry.save_telemetry_submission(data)[source]

Save a blob of data as the latest telemetry submission.

Naturally updates the latest submission time.

Parameters:data (dict) – A blob of data.
shuup.core.telemetry.daterange(start_date, end_date)[source]
shuup.core.telemetry.get_daily_data_for_day(date)[source]
shuup.core.telemetry.get_daily_data(today)[source]
shuup.core.telemetry.get_telemetry_data(request, indent=None)[source]

Get the telemetry data that would be sent.

Parameters:request (django.http.HttpRequest|None) – HTTP request. Optional.
Returns:Data blob.
Return type:str
exception shuup.core.telemetry.TelemetryNotSent(message, code)[source]

Bases: Exception

shuup.core.telemetry.try_send_telemetry(request=None, max_age_hours=24, raise_on_error=False)[source]

Send telemetry information (unless opted-out, in grace period or disabled).

Telemetry will be always sent if there is no prior sending information.

Parameters:
  • request (django.http.HttpRequest|None) – HTTP request. Optional.
  • max_age_hours (int|None) – How many hours must have passed since the last submission to be able to resend. If None, not checked.
  • raise_on_error (bool) – Raise exceptions when telemetry is not sent instead of quietly returning False.
Returns:

Sent data (possibly with response information) or False if not sent.

Return type:

dict|bool

Module contents

class shuup.core.ShuupCoreAppConfig(*args, **kwargs)[source]

Bases: shuup.apps.AppConfig

name = 'shuup.core'
verbose_name = 'Shuup Core'
label = 'shuup'
required_installed_apps = ('django.contrib.auth', 'django.contrib.contenttypes', 'easy_thumbnails', 'filer')
provides = {'pricing_module': ['shuup.core.pricing.default_pricing:DefaultPricingModule']}
ready()[source]