The next thing we do is define a standalone Python action script, /path/to/repo/www/chapter_6/details.py, which uses the product domain service and the graphic responder to render the photo and details on a specific product. As with the other scripts, we include a hashtag that instructs the web server's CGI process on how to handle the script. After that is a set of import statements:
#!/usr/bin/python
# tell python where to find source code
import os,sys
src_path = os.path.realpath('../../chapters/06/src')
sys.path.append(src_path)
import cgitb
cgitb.enable(display=1, logdir='../data')
from config.config import Config
from web.responder.html import HtmlResponder
from db.mongodb.connection import Connection
from sweetscomplete.domain.product import ProductService
from sweetscomplete.entity.product import Product
Next, we set up the database connection and product service using the Config class. We also initialize HtmlResponder:
config ...