cherrypy.config.update({ # http://www.cherrypy.org/wiki/ConfigAPI
'server.socket_host': options.address,
'server.socket_port': int(options.port),
+ 'tools.decode.on': True,
'tools.encode.on': True,
'tools.encode.encoding': 'utf8',
'tools.staticdir.root': static_dir,
'server.environment': 'production',
'server.socket_host': options.address,
'server.socket_port': int(options.port),
+ 'decoding_filter.on': True,
'encoding_filter.on': True,
'encodinf_filter.encoding': 'utf8',
'static_filter.on': True,
if name == None:
recipe = random.choice(self.cookbook)
else:
- if isinstance(name, types.StringType):
- name = unicode(name, 'utf-8')
recipe = self.cookbook.index[name]
template = self.env.get_template('recipe.html')
return template.render(cookbook=self.cookbook, recipe=recipe)
@cherrypy.expose
def add_tag(self, name, tag):
"""Add a tag to a single recipe."""
- if isinstance(name, types.StringType):
- name = unicode(name, 'utf-8')
recipe = self.cookbook.index[name]
if recipe.tags == None:
recipe.tags = []
@cherrypy.expose
def remove_tag(self, name, tag):
"""Remove a tag from a single recipe."""
- if isinstance(name, types.StringType):
- name = unicode(name, 'utf-8')
recipe = self.cookbook.index[name]
if recipe.tags == None:
return
def _clean_tag(self, tag):
"""Sanitize tag."""
- if not isinstance(tag, types.StringType):
+ if not isinstance(tag, types.StringTypes):
if len(tag) == 2 and '' in tag:
# User used either dropdown or textbox
tag.remove('')