Beispiel #1
0
    def _create_product(self):

        existing = Product.list(
            name=self._name,
            category=self._category,
            ptask=self._ptask.spec,
        )
        
        if len(existing) == 1:
            self._product = existing.pop()
            self._product.update(description=self._description)
            if self.interactive:
                print "\nBase product exists: " + \
                    Style.bright + self._product.spec + Style.reset
        else:
            try:
                self._product = Product.create(
                    ptask=self._ptask.spec,
                    name=self._name,
                    category=self._category,
                    description=self._description,
                    creator=current_username(),
                )
            except ProductError as e:
                raise ActionError("Unable to create product: " + str(e))
            else:
                if self.interactive:
                    print "\nCreated base product: " + \
                        Style.bright + self._product.spec + Style.reset