# Path: phylocommons/get_treestore.py
# def get_treestore():
#     return Treestore(**settings.TREESTORE_KWARGS)
# 
# def tree_id_from_uri(uri):
#     return Treestore.id_from_uri(uri, base_uri=settings.TREE_URI)
# 
# def uri_from_tree_id(tree_id):
#     return Treestore.uri_from_id(tree_id, base_uri=settings.TREE_URI)


from django.shortcuts import render_to_response, redirect
from django.http import HttpResponse
from django.core.context_processors import csrf
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
from django.template import RequestContext
from phylocommons.get_treestore import get_treestore, tree_id_from_uri, uri_from_tree_id
from forms import SearchForm
from cStringIO import StringIO
from phylocommons import settings
from django.forms.forms import NON_FIELD_ERRORS
from django.forms.util import ErrorList
from django.http import Http404
import Bio.Phylo as bp
import urllib
            errors.append(err_msg)
            
            return render_to_response(
                'list.html',
                params,
                context_instance=RequestContext(request)
            )
            
        trees = [(tree_id_from_uri(m[0]), int(m[1])) for m in trees]
        paginator = Paginator(trees, TREES_PER_PAGE)
        
        page = request.GET.get('page')
        try:
            tree_list = paginator.page(page)
        except PageNotAnInteger:
            # If page is not an integer, deliver first page.
            tree_list = paginator.page(1)
        except EmptyPage:
            # If page is out of range (e.g. 9999), deliver last page of results.
            tree_list = paginator.page(paginator.num_pages)
        
        params.update({'tree_list': tree_list,
                       'max_match_count': len(taxa)})

        num_pages = paginator.num_pages
        page_range = [n for n in range(tree_list.number - 2, tree_list.number + 3) 
                      if n >= 1 and n <= num_pages]

        params.update({
            'total_results': len(trees),

# Path: phylocommons/get_treestore.py
# def get_treestore():
#     return Treestore(**settings.TREESTORE_KWARGS)
# 
# def tree_id_from_uri(uri):
#     return Treestore.id_from_uri(uri, base_uri=settings.TREE_URI)
# 
# def uri_from_tree_id(tree_id):
#     return Treestore.uri_from_id(tree_id, base_uri=settings.TREE_URI)


# Path: treeview/views.py
from django.shortcuts import render_to_response, redirect
from django.http import HttpResponse
from django.core.context_processors import csrf
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
from django.template import RequestContext
from phylocommons.get_treestore import get_treestore, tree_id_from_uri, uri_from_tree_id
from forms import SearchForm
from cStringIO import StringIO
from phylocommons import settings
from django.forms.forms import NON_FIELD_ERRORS
from django.forms.util import ErrorList
from django.http import Http404
import Bio.Phylo as bp
import urllib

            errors.append(err_msg)
            
            return render_to_response(
                'list.html',
                params,
                context_instance=RequestContext(request)
            )
            
        trees = [(tree_id_from_uri(m[0]), int(m[1])) for m in trees]
        paginator = Paginator(trees, TREES_PER_PAGE)
        
        page = request.GET.get('page')
        try:
            tree_list = paginator.page(page)
        except PageNotAnInteger:
            # If page is not an integer, deliver first page.
            tree_list = paginator.page(1)
        except EmptyPage:
            # If page is out of range (e.g. 9999), deliver last page of results.
            tree_list = paginator.page(paginator.num_pages)
        
        params.update({'tree_list': tree_list,
                       'max_match_count': len(taxa)})

        num_pages = paginator.num_pages
        page_range = [n for n in range(tree_list.number - 2, tree_list.number + 3) 
                      if n >= 1 and n <= num_pages]

        params.update({
            'total_results': len(trees),

            'low_result': TREES_PER_PAGE * (tree_list.number - 1) + 1,