def insert_url(self, id, url, campaign, url_type): domain, url_path = utils.split_url(url) time_seen = datetime.now() self.update_urls_table(id, url, campaign, url_type, domain, url_path) self.update_domains_seen_table(campaign, domain, time_seen) self.update_slds_table(domain) self.update_campaigns_table(campaign, time_seen)
def import_data(self, data): try: endpoint, args = split_url(data['producto_url']) self.cantidad = int(data['cantidad']) except KeyError as e: raise ValidationError('Pedido no valido: perdido ' + e.args[0]) if endpoint != 'get_producto' or not 'id' in args: raise ValidationError('URL de producto no valido: ' + data['producto_url']) self.producto = Producto.query.get(args['id']) if self.producto is None: raise ValidationError('URL no valido de producto: ' + data['producto_url']) return self
def import_data(self, data): try: endpoint, args = split_url(data['product_url']) self.quantity = int(data['quantity']) except KeyError as e: raise ValidationError('Invalid order: missing ' + e.args[0]) if endpoint != 'get_product' or not 'id' in args: raise ValidationError('Invalid product URL: ' + data['product_url']) self.product = Product.query.get(args['id']) if self.product is None: raise ValidationError('Invalid product URL: ' + data['product_url']) return self
def import_data(self, data): try: endpoint, args = split_url(data['product_url']) self.quantity = int(data['quantity']) except KeyError as e: raise ValidationError('Invalid order: missing ' + e.args[0]) if endpoint != 'api.get_product' or not 'id' in args: raise ValidationError('Invalid product URL: ' + data['product_url']) self.product = Product.query.get(args['id']) if self.product is None: raise ValidationError('Invalid product URL: '+ data['product_url']) return self
def import_data(self, data): try: # split_url: https://gist.github.com/miguelgrinberg/9908687 # reverse of url_for(): decompose a URL into its parts # defined in the utils.py module endpoint, args = split_url(data['product_url']) self.quantity = int(data['quantity']) except KeyError as e: raise ValidationError('Invalid order: missing ' + e.args[0]) if endpoint != 'get_product' or not 'id' in args: raise ValidationError('Invalid product URL: ' + data['product_url']) self.product = Product.query.get(args['id']) if self.product is None: raise ValidationError('Invalid product URL: ' + data['product_url']) return self