Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

disuse interfaces

  • Loading branch information...
commit 2c8a919f1eabcadf0fa09de4075c0db657752d56 1 parent 03edcdc
Chris McDonough mcdonc authored
Showing with 9 additions and 42 deletions.
  1. +0 −22 virginia/interfaces.py
  2. +0 −11 virginia/models.py
  3. +9 −9 virginia/views.py
22 virginia/interfaces.py
View
@@ -1,22 +0,0 @@
-from zope.interface import Interface
-
-class IFilesystem(Interface):
- """ Marker interface for a filesystem object
- """
-
-class IDirectory(Interface):
- """ Marker interface for directories
- """
-
-class IFile(Interface):
- """ Marker interface for files
- """
-
-class IStructuredText(Interface):
- """ Marker interface for structured text documents
- """
-
-
-
-
-
11 virginia/models.py
View
@@ -1,14 +1,6 @@
import os
-from zope.interface import implements
-
-from virginia.interfaces import IFile
-from virginia.interfaces import IDirectory
-from virginia.interfaces import IFilesystem
-
class Filesystem(object):
- implements(IFilesystem)
-
def __init__(self, root_path):
self.root_path = os.path.abspath(os.path.normpath(root_path))
@@ -27,8 +19,6 @@ def read(self, path):
return self.open(path).read()
class File(object):
- implements(IFile)
-
def __init__(self, filesystem, path):
self.filesystem = filesystem
self.path = os.path.abspath(os.path.normpath(path))
@@ -41,7 +31,6 @@ def _source(self):
class Directory(object):
file_class = File
- implements(IDirectory)
def __init__(self, filesystem, path):
self.filesystem = filesystem
self.path = os.path.abspath(os.path.normpath(path))
18 virginia/views.py
View
@@ -12,19 +12,19 @@
from pyramid.view import render_view_to_response
from pyramid.view import view_config
-from virginia.interfaces import IFile
-from virginia.interfaces import IDirectory
+from virginia.models import File
+from virginia.models import Directory
# default views: router will call these
-@view_config(context=IFile)
+@view_config(context=File)
def file_view(context, request):
dirname, filename = os.path.split(context.path)
name, ext = os.path.splitext(filename)
result = render_view_to_response(context, request, ext)
return result
-@view_config(context=IDirectory)
+@view_config(context=Directory)
def directory_view(context, request):
path_info = request.environ['PATH_INFO']
if not path_info.endswith('/'):
@@ -44,7 +44,7 @@ def directory_view(context, request):
# custom views: FileView will call these
-@view_config(context=IFile, name='.stx')
+@view_config(context=File, name='.stx')
def structured_text_view(context, request):
""" Filesystem-based STX view
"""
@@ -53,10 +53,10 @@ def structured_text_view(context, request):
response.content_type = 'text/html'
return response
-@view_config(context=IFile, name='.html')
-@view_config(context=IFile, name='.pdf')
-@view_config(context=IFile, name='.txt')
-@view_config(context=IFile, name='.jpg')
+@view_config(context=File, name='.html')
+@view_config(context=File, name='.pdf')
+@view_config(context=File, name='.txt')
+@view_config(context=File, name='.jpg')
def raw_view(context, request):
""" Just return the source raw.
"""
Please sign in to comment.
Something went wrong with that request. Please try again.