[docs]classCoreposHandler(GenericHandler):""" Base class and default implementation for the CORE-POS integration :term:`handler`. """
[docs]defget_model_office_op(self):""" Returns the :term:`data model` module for CORE Office 'op' DB, i.e. :mod:`pycorepos:corepos.db.office_op.model`. """fromcorepos.db.office_opimportmodelreturnmodel
[docs]defget_model_office_trans(self):""" Returns the :term:`data model` module for CORE Office 'trans' DB, i.e. :mod:`pycorepos:corepos.db.office_trans.model`. """fromcorepos.db.office_transimportmodelreturnmodel
[docs]defget_model_office_arch(self):""" Returns the :term:`data model` module for CORE Office 'arch' DB, i.e. :mod:`pycorepos:corepos.db.office_arch.model`. """fromcorepos.db.office_archimportmodelreturnmodel
[docs]defmake_session_office_op(self,dbkey='default',**kwargs):""" Make a new :term:`db session` for the CORE Office 'op' DB. :returns: Instance of :class:`pycorepos:corepos.db.office_op.Session`. """fromcorepos.db.office_opimportSessionif'bind'notinkwargs:kwargs['bind']=self.config.core_office_op_engines[dbkey]returnSession(**kwargs)
[docs]defmake_session_office_trans(self,dbkey='default',**kwargs):""" Make a new :term:`db session` for the CORE Office 'trans' DB. :returns: Instance of :class:`pycorepos:corepos.db.office_trans.Session`. """fromcorepos.db.office_transimportSessionif'bind'notinkwargs:kwargs['bind']=self.config.core_office_trans_engines[dbkey]returnSession(**kwargs)
[docs]defmake_session_office_arch(self,dbkey='default',**kwargs):""" Make a new :term:`db session` for the CORE Office 'arch' DB. :returns: Instance of :class:`pycorepos:corepos.db.office_arch.Session`. """fromcorepos.db.office_archimportSessionif'bind'notinkwargs:kwargs['bind']=self.config.core_office_arch_engines[dbkey]returnSession(**kwargs)
[docs]defget_office_url(self,require=False):""" Returns the base URL for the CORE Office web app. Note that the return value is stripped of final slash. :param require: If true, an error is raised when URL cannot be determined. :returns: URL as string. """url=self.config.get('corepos.office.url',require=require)ifurl:returnurl.rstrip('/')
[docs]defget_office_department_url(self,dept_id,office_url=None,require=False):""" Returns the CORE Office URL for a Department. :param dept_id: Department ID for the URL. :param office_url: Root URL from :meth:`get_office_url()`. :param require: If true, an error is raised when URL cannot be determined. :returns: URL as string. """ifnotoffice_url:office_url=self.get_office_url(require=require)ifoffice_url:returnf'{office_url}/item/departments/DepartmentEditor.php?did={dept_id}'
[docs]defget_office_likecode_url(self,likecode_id,office_url=None,require=False):""" Returns the CORE Office URL for a Like Code. :param likecode_id: Like Code ID for the URL. :param office_url: Root URL from :meth:`get_office_url()`. :param require: If true, an error is raised when URL cannot be determined. :returns: URL as string. """ifnotoffice_url:office_url=self.get_office_url(require=require)ifoffice_url:returnf'{office_url}/item/likecodes/LikeCodeEditor.php?start={likecode_id}'
[docs]defget_office_product_url(self,upc,office_url=None,require=False):""" Returns the CORE Office URL for a Product. :param upc: UPC for the URL. :param office_url: Root URL from :meth:`get_office_url()`. :param require: If true, an error is raised when URL cannot be determined. :returns: URL as string. """ifnotoffice_url:office_url=self.get_office_url(require=require)ifoffice_url:returnf'{office_url}/item/ItemEditorPage.php?searchupc={upc}'
[docs]defget_office_vendor_url(self,vend_id,office_url=None,require=False):""" Returns the CORE Office URL for a Vendor. :param vend_id: Vendor ID for the URL. :param office_url: Root URL from :meth:`get_office_url()`. :param require: If true, an error is raised when URL cannot be determined. :returns: URL as string. """ifnotoffice_url:office_url=self.get_office_url(require=require)ifoffice_url:returnf'{office_url}/item/vendors/VendorIndexPage.php?vid={vend_id}'