MambuPy.rest.mambuproduct

Mambu Products objects.

MambuProduct holds a product.

MambuProducts holds a list of products.

Uses mambugeturl.getproducturl as default urlfunc

Classes

AllMambuProducts(*args, **kwargs)

Singleton that holds ALL the Mambu products.

MambuProduct([urlfunc, entid])

A Product from Mambu.

MambuProducts([urlfunc, entid])

A list of Products from Mambu.

class MambuPy.rest.mambuproduct.AllMambuProducts(*args, **kwargs)[source]

Bases: MambuStruct

Singleton that holds ALL the Mambu products.

With the default urlfunc, entid argument must be empty at instantiation time to retrieve all the products according to any other filter you send to the urlfunc.

Caching singleton. You may not wish to retrieve from Mambu all the products every time you need to use them, so you can use this, which requests from Mambu one time only, and holds them here forever during your python session.

To use it, instead of instantiating a MambuProducts() object when needing all the products from Mambu, instantiate an AllMambuProducts() object and the caching will be used by default.

Todo

is there a better way to implement cache directly on

MambuProducts()?

Why have a cache? because Mambu products are not likely to change once you have them configured in Mambu. So it’s better to prevent a lot of requests to get the same information over and over again.

You are free to implement caches such as this on any other Mambu objects if you find it useful (perhaps groups or branches or any other Mambu entity do not change a lot on your own business?). Please try to be consistent on names and functionality.

__getattribute__(name)[source]

Object-like get attribute

__init__(urlfunc=<function getproductsurl>, entid='', *args, **kwargs)[source]

If you have already retrieved products, you don’t contact Mambu. If you haven’t, you do.

__instance = None
__iter__()[source]
__module__ = 'MambuPy.rest.mambuproduct'
static __new__(cls, *args, **kwargs)[source]
convert_dict_to_attrs(*args, **kwargs)[source]

The trick for iterable Mambu Objects comes here:

You iterate over each element of the responded List from Mambu, and create a Mambu Product object for each one, initializing them one at a time, and changing the attrs attribute (which just holds a list of plain dictionaries) with a MambuProduct just created.

Todo

pass a valid (perhaps default) urlfunc, and its corresponding id to entid to each MambuProduct, telling MambuStruct not to connect() by default. It’s desirable to connect at any other further moment to refresh some element in the list.

class MambuPy.rest.mambuproduct.MambuProduct(urlfunc=<function getproductsurl>, entid='', *args, **kwargs)[source]

Bases: MambuStruct

A Product from Mambu.

With the default urlfunc, entid argument must be the ID of the product you wish to retrieve.

__init__(urlfunc=<function getproductsurl>, entid='', *args, **kwargs)[source]

Tasks done here:

Just initializes the MambuStruct.

__module__ = 'MambuPy.rest.mambuproduct'
class MambuPy.rest.mambuproduct.MambuProducts(urlfunc=<function getproductsurl>, entid='', *args, **kwargs)[source]

Bases: MambuStruct

A list of Products from Mambu.

With the default urlfunc, entid argument must be empty at instantiation time to retrieve all the products according to any other filter you send to the urlfunc.

__init__(urlfunc=<function getproductsurl>, entid='', *args, **kwargs)[source]

By default, entid argument is empty. That makes perfect sense: you want several products, not just one

__iter__()[source]
__module__ = 'MambuPy.rest.mambuproduct'
convert_dict_to_attrs(*args, **kwargs)[source]

The trick for iterable Mambu Objects comes here:

You iterate over each element of the responded List from Mambu, and create a Mambu Product object for each one, initializing them one at a time, and changing the attrs attribute (which just holds a list of plain dictionaries) with a MambuProduct just created.

Todo

pass a valid (perhaps default) urlfunc, and its corresponding id to entid to each MambuProduct, telling MambuStruct not to connect() by default. It’s desirable to connect at any other further moment to refresh some element in the list.