# Path: cms/dbutil.py
# def get_mongodb(request):
# def get_collection(request, name):
# def get_gridfs(request, collection='fs'):
# def encode_keys(d):
# def get_es_conn(request):
# def get_es_index_name(request):
# def serve_gridfs_file(file):
# def serve_gridfs_file_for_id(request, id, collection='fs'):
# 
# Path: cms/htmlutil.py
# def html_to_text(html, show_link_urls=1, skip_tags=[], unknown_entity_replacement=None):
#     output_unicode = False
#     if type(html) == unicode:
#         html = html.encode('utf-8')
#         output_unicode = True
# 
#     textout = cStringIO.StringIO()
#     formtext = formatter.AbstractFormatter(formatter.DumbWriter(textout))
#     parser = HTML_to_text_parser(formtext, show_link_urls, skip_tags, unknown_entity_replacement)
# 
#     # Annoyingly HTMLParser doesn't handle self-closing tags without a space
#     # (such as "<br/>") properly.
#     # So let's add any missing spaces (for example, "<br />").
#     html = SELF_CLOSING_FIX_RE.sub(r'\1 />', html)
# 
#     parser.feed(html)
#     parser.close()
#     text = textout.getvalue().strip()
#     del textout, formtext, parser
#     if output_unicode: return unicode(text, 'utf-8')
#     else: return text


from object import Object
from cms import dbutil
from bson.objectid import ObjectId
from cms.htmlutil import html_to_text
from pyramid import security
from interfaces import IContent, ITrash
import colander, deform
import widgets
import permissions
import repoze.workflow
import zope.interface
import pyes
import logging
        mapping['_view'] = dict(type='string', include_in_all=False, index='not_analyzed')
        mapping['_pub_state'] = dict(type='string', include_in_all=False, index='not_analyzed')
        mapping['_id_path'] = dict(type='string', include_in_all=False, index='not_analyzed')
        mapping['_object_type'] = dict(type='string', include_in_all=False, index='not_analyzed')
        mapping['title'] = dict(type='string', include_in_all=True, boost=4.0)
        mapping['sortable_title'] = dict(type='string', include_in_all=False, index='not_analyzed')
        mapping['description'] = dict(type='string', include_in_all=True, boost=2.0)
        mapping['other_text'] = dict(type='string', include_in_all=True)
        mapping['_created'] = dict(type='date', format='dateOptionalTime', include_in_all=False)
        mapping['_modified'] = dict(type='date', format='dateOptionalTime', include_in_all=False)
        return mapping
    _get_es_mapping = classmethod(_get_es_mapping)

    def _get_es_document(self):
        doc = dict(__name__ = self.__name__,
                   _object_type = self._object_type,
                   title = self.title,
                   sortable_title = self.sortable_title.lower(),
                   description = self.description,
                   _created = self._created,
                   _modified = self._modified,
                   _id_path = [str(x) for x in self.get_id_path()],
                  )
        doc['_view'] = self._get_view_principals()
        _pub_state = self.get_pub_state()
        if _pub_state: doc['_pub_state'] = _pub_state
        doc['other_text'] = self.get_es_other_text()
        return doc

    def index(self):

# Path: cms/dbutil.py
# def get_mongodb(request):
# def get_collection(request, name):
# def get_gridfs(request, collection='fs'):
# def encode_keys(d):
# def get_es_conn(request):
# def get_es_index_name(request):
# def serve_gridfs_file(file):
# def serve_gridfs_file_for_id(request, id, collection='fs'):
# 
# Path: cms/htmlutil.py
# def html_to_text(html, show_link_urls=1, skip_tags=[], unknown_entity_replacement=None):
#     output_unicode = False
#     if type(html) == unicode:
#         html = html.encode('utf-8')
#         output_unicode = True
# 
#     textout = cStringIO.StringIO()
#     formtext = formatter.AbstractFormatter(formatter.DumbWriter(textout))
#     parser = HTML_to_text_parser(formtext, show_link_urls, skip_tags, unknown_entity_replacement)
# 
#     # Annoyingly HTMLParser doesn't handle self-closing tags without a space
#     # (such as "<br/>") properly.
#     # So let's add any missing spaces (for example, "<br />").
#     html = SELF_CLOSING_FIX_RE.sub(r'\1 />', html)
# 
#     parser.feed(html)
#     parser.close()
#     text = textout.getvalue().strip()
#     del textout, formtext, parser
#     if output_unicode: return unicode(text, 'utf-8')
#     else: return text


# Path: cms/resources/content.py
from object import Object
from cms import dbutil
from bson.objectid import ObjectId
from cms.htmlutil import html_to_text
from pyramid import security
from interfaces import IContent, ITrash
import colander, deform
import widgets
import permissions
import repoze.workflow
import zope.interface
import pyes
import logging

        mapping['_view'] = dict(type='string', include_in_all=False, index='not_analyzed')
        mapping['_pub_state'] = dict(type='string', include_in_all=False, index='not_analyzed')
        mapping['_id_path'] = dict(type='string', include_in_all=False, index='not_analyzed')
        mapping['_object_type'] = dict(type='string', include_in_all=False, index='not_analyzed')
        mapping['title'] = dict(type='string', include_in_all=True, boost=4.0)
        mapping['sortable_title'] = dict(type='string', include_in_all=False, index='not_analyzed')
        mapping['description'] = dict(type='string', include_in_all=True, boost=2.0)
        mapping['other_text'] = dict(type='string', include_in_all=True)
        mapping['_created'] = dict(type='date', format='dateOptionalTime', include_in_all=False)
        mapping['_modified'] = dict(type='date', format='dateOptionalTime', include_in_all=False)
        return mapping
    _get_es_mapping = classmethod(_get_es_mapping)

    def _get_es_document(self):
        doc = dict(__name__ = self.__name__,
                   _object_type = self._object_type,
                   title = self.title,
                   sortable_title = self.sortable_title.lower(),
                   description = self.description,
                   _created = self._created,
                   _modified = self._modified,
                   _id_path = [str(x) for x in self.get_id_path()],
                  )
        doc['_view'] = self._get_view_principals()
        _pub_state = self.get_pub_state()
        if _pub_state: doc['_pub_state'] = _pub_state
        doc['other_text'] = self.get_es_other_text()
        return doc

    def index(self):

        dbutil.get_es_conn(self.request).index(self._get_es_document(), dbutil.get_es_index_name(self.request), self._get_es_doctype(), str(self._id))