Index: tracvote/__init__.py
===================================================================
--- tracvote/__init__.py	(revision 16921)
+++ tracvote/__init__.py	(working copy)
@@ -27,7 +27,7 @@
 from trac.env import IEnvironmentSetupParticipant
 from trac.perm import IPermissionRequestor
 from trac.resource import Resource, ResourceSystem, get_resource_description
-from trac.resource import get_resource_url, resource_exists
+from trac.resource import get_resource_url
 from trac.ticket.api import IMilestoneChangeListener
 from trac.util import as_int, get_reporter_id
 from trac.util.datefmt import format_datetime, to_datetime, to_utimestamp, utc
@@ -46,59 +46,6 @@
 pkg_resources.require('Trac >= 1.0')
 
 
-def get_versioned_resource(env, resource):
-    """Find the current version for a Trac resource.
-
-    Because versioned resources with no version value default to 'latest',
-    the current version has to be retrieved separately.
-    """
-    realm = resource.realm
-    if realm == 'ticket':
-        for count, in env.db_query("""
-                SELECT COUNT(DISTINCT time)
-                FROM ticket_change WHERE ticket=%s
-                """, (resource.id,)):
-            if count != 0:
-                resource.version = count
-    elif realm == 'wiki':
-        for version, in env.db_query("""
-                SELECT version
-                  FROM wiki
-                 WHERE name=%s
-                 ORDER BY version DESC LIMIT 1
-                """, (resource.id,)):
-            resource.version = version
-    return resource
-
-
-def _resource_exists(env, resource):
-    """Avoid exception in database for Trac < 1.0.7.
-    http://trac.edgewall.org/ticket/12076
-    """
-    try:
-        return resource_exists(env, resource)
-    except env.db_exc.DatabaseError:
-        return False
-
-
-def resource_from_path(env, path):
-    """Find realm and resource ID from resource URL.
-
-    Assuming simple resource paths to convert to Trac resource identifiers.
-    """
-    if isinstance(path, basestring):
-        path = path.strip('/')
-        # Special-case: Default TracWiki start page.
-        if path == 'wiki':
-            path += '/WikiStart'
-    for realm in ResourceSystem(env).get_known_realms():
-        if path.startswith(realm):
-            resource_id = re.sub(realm, '', path, 1).lstrip('/')
-            resource = Resource(realm, resource_id)
-            if _resource_exists(env, resource) in (None, True):
-                return get_versioned_resource(env, resource)
-
-
 class VoteSystem(Component):
     """Allow up- and down-voting on Trac resources."""
 
@@ -512,7 +459,7 @@
 
         elif name == 'VoteList':
             lst = tag.ul()
-            resource = resource_from_path(env, req.path_info)
+            resource = formatter.context.resource
             for i in self.get_votes(req, resource, top=top):
                 vote = _("at %(date)s",
                          date=format_datetime(to_datetime(i[4])))
Index: tracvote/tests/main.py
===================================================================
--- tracvote/tests/main.py	(revision 16920)
+++ tracvote/tests/main.py	(working copy)
@@ -33,7 +33,8 @@
 except ImportError:
     from trac.web.api import HTTPInternalError
 
-from tracvote import VoteSystem, resource_from_path
+from tracvote import VoteSystem
+from tracvote.upgrades.db2 import resource_from_path
 
 
 _ACTIONS = dict(view='VOTE_VIEW', modify='VOTE_MODIFY')
Index: tracvote/upgrades/db2.py
===================================================================
--- tracvote/upgrades/db2.py	(revision 16920)
+++ tracvote/upgrades/db2.py	(working copy)
@@ -9,9 +9,8 @@
 
 import re
 
-from trac.db import Table, Column, Index, DatabaseManager
-
-from tracvote import resource_from_path
+from trac.db import Table, Column, DatabaseManager
+from trac.resource import Resource, ResourceSystem, resource_exists
 
 
 schema = [
@@ -27,6 +26,58 @@
     ]
 
 
+def get_versioned_resource(env, resource):
+    """Find the current version for a Trac resource.
+
+    Because versioned resources with no version value default to 'latest',
+    the current version has to be retrieved separately.
+    """
+    realm = resource.realm
+    if realm == 'ticket':
+        for count, in env.db_query("""
+                SELECT COUNT(DISTINCT time)
+                FROM ticket_change WHERE ticket=%s
+                """, (resource.id,)):
+            if count != 0:
+                resource.version = count
+    elif realm == 'wiki':
+        for version, in env.db_query("""
+                SELECT version
+                  FROM wiki
+                 WHERE name=%s
+                 ORDER BY version DESC LIMIT 1
+                """, (resource.id,)):
+            resource.version = version
+    return resource
+
+
+def _resource_exists(env, resource):
+    """Avoid exception in database for Trac < 1.0.7.
+    http://trac.edgewall.org/ticket/12076
+    """
+    try:
+        return resource_exists(env, resource)
+    except env.db_exc.DatabaseError:
+        return False
+
+
+def resource_from_path(env, path):
+    """Find realm and resource ID from resource URL.
+
+    Assuming simple resource paths to convert to Trac resource identifiers.
+    """
+    path = path.strip('/')
+    # Special-case: Default TracWiki start page.
+    if path == 'wiki':
+        path += '/WikiStart'
+    for realm in ResourceSystem(env).get_known_realms():
+        if path.startswith(realm):
+            resource_id = re.sub(realm, '', path, 1).lstrip('/')
+            resource = Resource(realm, resource_id)
+            if _resource_exists(env, resource) in (None, True):
+                return get_versioned_resource(env, resource)
+
+
 def do_upgrade(env, ver, cursor):
     """Changes to votes db table:
 
