rattail.vendors.handler

Vendors Handler

class rattail.vendors.handler.VendorHandler(config, **kwargs)[source]

Base class and default implementation for vendor handlers.

choice_uses_dropdown()[source]

Returns boolean indicating whether a vendor choice should be presented to the user via a dropdown (select) element, vs. an autocomplete field. The latter is the default because potentially the vendor list can be quite large, so we avoid loading them all in the dropdown unless so configured.

Returns:

Boolean; if true then a dropdown should be used; otherwise (false) autocomplete is used.

get_all_catalog_parsers()[source]

Should return all catalog parsers known to exist.

Note that this returns classes and not instances.

Returns:

List of CatalogParser classes.

get_catalog_parser(key, require=False)[source]

Retrieve the catalog parser for the given parser key.

Note that this returns an instance, not the class.

Parameters:

key – Unique key indicating which parser to get.

Returns:

A CatalogParser instance.

get_supported_catalog_parsers()[source]

Should return only those catalog parsers which are “supported” by the current app. Usually “supported” just means what we want to expose to the user.

Note that this returns classes and not instances.

Returns:

List of CatalogParser classes.

get_vendor(session, key, **kwargs)[source]

Locate and return the vendor corresponding to the given key.

The key can be a UUID value, but most often it will instead be a “generic” key specific to this purpose. Any generic key can be defined within the settings, pointing to a valid vendor.

For instance, we can define a key of 'poser.acme' to denote the hypothetical “Acme Distribution” vendor, and we add a namespace unique to our app just to be safe.

We then create a setting in the DB pointing to our actual vendor by way of its UUID:

INSERT INTO SETTING (name, value) 
VALUES ('rattail.vendor.poser.acme',
        '7e6d69a2700911ec93533ca9f40bc550');

From then on we could easily fetch the vendor by this key. This is mainly useful to allow catalog and invoice parsers to “loosely” associate with a particular vendor by way of this key, which could be shared across organizations etc.

Parameters:
  • session – Active database session.

  • key – Value to use when searching for the vendor.

Returns:

The Vendor instance if found; otherwise None.