Push Base Module

class pubtools._content_gateway.push_base.PushBase(cgw_hostname, cgw_username, cgw_password)[source]

Bases: object

Base class for all operations on content gateway via either through entry points or from staged input.

Adds arguments and environment variables common to all operations.

make_visible()[source]
  • Update the invisible attribute to False. once all the CGW operation completed successfully.

  • This is needed to make the version and file records visible.

  • The invisible attribute changes on the following conditions:

    • invisible=True :- sets if user externally specify the invisible=True

    • invisible=False :- sets either if user externally specify the invisible=False or user doesn’t specify any value for this invisible attribute.

process_file(file_item)[source]

Responsible for file workflow operations such as Create, Update and delete the file based on the satisfied condition on content gateway (CGW).

The file operation follows the following workflow:
  • Search for the product record from the product mapping

  • Search for the product version record from the product_version (pv_mapping) mapping

  • Search for the file record from the file mapping (file_mapping) mapping

  • If file action == create

    • Creates a new file record associated with product on CGW with given data

    • Add the new record into the file mapping records

  • If file action == update and record found in mapping or id is provided in metadata

    • Update the file record on content gateway with given data

    • Update the record into the file mapping records

  • If file action == delete and record found in mapping or id is provided in metadata

    • Delete the file record on the content gateway

    • Remove the record from the file mapping records

  • If file action == delete or update and record not found in mapping or id is not provided in metadata

    • Raises CGWError error

  • The default file order value will be 10 if provided none

  • file order will be auto incremented by 10 for nested data yml structure

Parameters

file_item (dict) – Metadata of file record

Raises

CGWError

  • When product record is not present - When version record is not present - When file record is not present and tries to update/delete the same

Returns

Returns the file ID

Return type

file_id (int|None)

process_product(item)[source]

Responsible for product workflow operations such as Create, Update and delete the product based on the satisfied condition.

The product operation follows the following workflow:
  • Search for the product record from the product mapping

  • If product action == create

    • Creates a new product record on content gateway with given data

    • Add the new record into the product mapping records

  • If product action == update and record found in mapping or id is provided in metadata

    • Update the product record on content gateway with given data

    • Update the record into the product mapping records

  • If product action == delete and record found in mapping or id is provided in metadata

    • Delete the product record on the content gateway

    • Remove the record from the product mapping records

  • If product action == delete or update and record not found in mapping

    • Raises CGWError error

Parameters

item (dict) – Metadata of product record

Raises

CGWError – When product record is not present and tries to update/delete the same

Returns

Returns the product ID

Return type

product_id (int)

process_version(item)[source]

Responsible for version workflow operations such as Create, Update and delete the product version based on the satisfied condition on content gateway (CGW).

The product version operation follows the following workflow:
  • Search for the product record from the product mapping

  • Search for the product version record from the product_version(pv_mapping) mapping

  • If version action == create

    • Creates a new version record associated with product on CGW with given data

    • Add the new record into the mapping records

  • If version action == update and record found in mapping or id is provided in metadata

    • Update the version record on content gateway with given data

    • Update the record into the version mapping records

  • If version action == delete and record found in mapping or id is provided in metadata

    • Delete the version record on the content gateway

    • Remove the record from the version mapping records

  • If version action == delete or update and record not found in mapping

    or id is not provided in metadata

    • Raises CGWError error

Parameters

item (dict) – Metadata of version record

Raises

CGWError

  • When product record is not present - When version record is not present and tries to update/delete the same

Returns

Returns the version ID

Return type

version_id (int|None)

rollback_cgw_operation()[source]
Undo the partial completed CGW operation.
  • For the create operations it will delete the created data from CGW

  • For the update operation it will revert the changes with old data.