Commit bf9aa29a authored by Michal Čihař's avatar Michal Čihař

Add method for accessing indexes

parent 603ba469
......@@ -9,6 +9,9 @@ from django.db.models.signals import post_syncdb
from django.conf import settings
from whoosh import index
ix_translation = None
ix_source = None
class TranslationSchema(SchemaClass):
unit = ID(stored = True)
target = TEXT
......@@ -34,3 +37,19 @@ def create_index(sender=None, **kwargs):
)
post_syncdb.connect(create_index)
def get_ix_source():
if ix_source is None:
ix_source = index.open_dir(
settings.WHOOSH_INDEX,
indexname = 'source'
)
return ix_source
def get_ix_translationg():
if ix_translationg is None:
ix_translationg = index.open_dir(
settings.WHOOSH_INDEX,
indexname = 'translationg'
)
return ix_translationg
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment