def slugify(text, delim=u'-'): """Generates an slightly worse ASCII-only slug. Taken from the Flask Snippets page. :param text: The text which should be slugified :param delim: Default "-". The delimeter for whitespace """ text = unidecode.unidecode(text) result = [] for word in _punct_re.split(text.lower()): if word: result.append(word) return text_type(delim.join(result))
def insert_forum(cls, writer, forum): writer.add_document(forum_id=forum.id, title=text_type(forum.title), description=text_type(forum.description))
def update_forum(cls, writer, forum): writer.update_document(forum_id=forum.id, title=text_type(forum.title), description=text_type(forum.description))
def insert_topic(cls, writer, topic): writer.add_document(topic_id=topic.id, title=text_type(topic.title), username=text_type(topic.username), content=text_type( getattr(topic.first_post, 'content', None)))
def insert_post(cls, writer, post): writer.add_document(post_id=post.id, username=text_type(post.username), modified_by=text_type(post.modified_by), content=text_type(post.content))
def insert_user(cls, writer, user): writer.add_document(user_id=user.id, username=text_type(user.username), email=text_type(user.email))
def update_user(cls, writer, user): writer.update_document(user_id=user.id, username=text_type(user.username), email=text_type(user.email))