Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Remove dependency on zope.cachedescriptors.

Looks like I can do the same things with Brownie,
and the syntax is a bit more pleasant. No need to
use both.

Also removed the compressinja dependency since it
is not being used.
  • Loading branch information...
commit ab081ac02489f3d610f815587111af7fbf74ddb3 1 parent ca33a5a
@tylerbutler authored
View
21 engineer/conf.py
@@ -11,9 +11,8 @@
from jinja2 import Environment, FileSystemLoader, FileSystemBytecodeCache
from typogrify.templatetags.jinja2_filters import register
from path import path
-from zope.cachedescriptors import property as zproperty
+from brownie.caching import cached_property
from engineer.cache import SimpleFileCache
-from engineer.enums import Status
from engineer.filters import typogrify_no_widont
from engineer.plugins import get_all_plugin_types
from engineer.util import urljoin, slugify, ensure_exists, wrap_list, update_additive
@@ -283,11 +282,11 @@ def _check_deprecated_settings(self, config):
if config.pop(setting[0], None) is not None:
logger.warning("The '%s' setting was deprecated in version %s: %s" % setting)
- @zproperty.CachedProperty
+ @cached_property
def OUTPUT_STATIC_DIR(self):
return path(self.OUTPUT_CACHE_DIR / self.ENGINEER.STATIC_DIR.basename()).abspath()
- @zproperty.CachedProperty
+ @cached_property
def JINJA_ENV(self):
from engineer.filters import format_datetime, markdown_filter, localtime, naturaltime, compress
from engineer.processors import preprocess_less
@@ -335,8 +334,14 @@ def urlname(name, *args):
env.globals['settings'] = self
return env
- @zproperty.CachedProperty
+ @cached_property
def CACHE(self):
+ # This check is a hack to ensure sphinx autodoc doesn't choke on this property.
+ # I don't know why it chokes here, but I think the exception handling might be
+ # messing with it.
+ if self is None:
+ return
+
# Use a shelf as the main cache
try:
CACHE = shelve.open(self.CACHE_FILE, writeback=True)
@@ -350,19 +355,19 @@ def CACHE(self):
CACHE['version'] = version
return CACHE
- @zproperty.CachedProperty
+ @cached_property
def COMPRESSION_CACHE(self):
if not self.CACHE.has_key('COMPRESSION_CACHE'):
self.CACHE['COMPRESSION_CACHE'] = SimpleFileCache(version=version)
return self.CACHE['COMPRESSION_CACHE']
- @zproperty.CachedProperty
+ @cached_property
def POST_CACHE(self):
if not self.CACHE.has_key('POST_CACHE'):
self.CACHE['POST_CACHE'] = SimpleFileCache(version=version)
return self.CACHE['POST_CACHE']
- @zproperty.CachedProperty
+ @cached_property
def LESS_CACHE(self):
if not self.CACHE.has_key('LESS_CACHE'):
self.CACHE['LESS_CACHE'] = SimpleFileCache(version=version)
View
2  engineer/docs_source/conf.py
@@ -58,7 +58,7 @@
# General information about the project.
project = APP_NAME
-copyright = u'2011, %s' % AUTHOR_NAME
+copyright = u'2011-2012, %s' % AUTHOR_NAME
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
View
2  engineer/docs_source/intro.rst
@@ -134,11 +134,9 @@ complete set of packages Engineer depends on is as follows:
* flufl.enum
* translitcodec
* jinja2
-* compressinja
* pygments
* html5lib
* python-dateutil
-* zope.cachedescriptors
* humanize
* bottle
* pytz
View
2  engineer/log.py
@@ -1,5 +1,5 @@
# coding=utf-8
-import sys, platform
+import sys
import logging
from brownie.caching import memoize
from engineer.lib.ansistrm import ColorizingStreamHandler
View
18 engineer/models.py
@@ -7,12 +7,12 @@
from codecs import open
from copy import copy
from datetime import datetime
+from brownie.caching import cached_property
from dateutil import parser
from path import path
from propane.datastructures import CaseInsensitiveDict
from typogrify.templatetags.jinja2_filters import typogrify
from yaml.scanner import ScannerError
-from zope.cachedescriptors.property import CachedProperty
from engineer.conf import settings
from engineer.enums import Status
from engineer.exceptions import PostMetadataError
@@ -149,7 +149,7 @@ def __init__(self, source):
# update cache
settings.POST_CACHE[self.source] = self
- @CachedProperty
+ @cached_property
def url(self):
"""The site-relative URL to the post."""
url = u'{home_url}{permalink}'.format(home_url=settings.HOME_URL,
@@ -157,19 +157,19 @@ def url(self):
url = re.sub(r'/{2,}', r'/', url)
return url
- @CachedProperty
+ @cached_property
def absolute_url(self):
"""The absolute URL to the post."""
return u'{0}{1}'.format(settings.SITE_URL, self.url)
- @CachedProperty
+ @cached_property
def output_path(self):
url = self._permalink
if url.endswith('/'):
url += 'index.html'
return path(settings.OUTPUT_CACHE_DIR / url)
- @CachedProperty
+ @cached_property
def output_file_name(self):
r = self.output_path.name
return r
@@ -283,12 +283,12 @@ def paginate(self, paginate_by=None):
paginate_by = settings.ROLLUP_PAGE_SIZE
return chunk(self, paginate_by, PostCollection)
- @CachedProperty
+ @cached_property
def published(self):
"""Returns a new PostCollection containing the subset of posts that are published."""
return PostCollection([p for p in self if p.is_published == True])
- @CachedProperty
+ @cached_property
def drafts(self):
"""Returns a new PostCollection containing the subset of posts that are drafts."""
return PostCollection([p for p in self if p.is_draft == True])
@@ -298,12 +298,12 @@ def pending(self):
"""Returns a new PostCollection containing the subset of posts that are pending."""
return PostCollection([p for p in self if p.is_pending == True])
- @CachedProperty
+ @cached_property
def review(self):
"""Returns a new PostCollection containing the subset of posts whose status is :attr:`~Status.review`."""
return PostCollection([p for p in self if p.status == Status.review])
- @CachedProperty
+ @cached_property
def all_tags(self):
"""Returns a list of all the unique tags, as strings, that posts in the collection have."""
tags = set()
View
10 engineer/themes.py
@@ -1,8 +1,8 @@
# coding=utf-8
from jinja2.loaders import FileSystemLoader
import yaml
+from brownie.caching import memoize
from path import path
-from zope.cachedescriptors import method
from engineer.conf import settings
from engineer.exceptions import ThemeNotFoundException
from engineer.util import get_class
@@ -90,7 +90,7 @@ def __unicode__(self):
class ThemeManager(object):
@classmethod
- @method.cachedIn('_cache')
+ @memoize
def themes(cls):
themes = []
for f in settings.THEME_FINDERS:
@@ -99,7 +99,7 @@ def themes(cls):
return dict([t.id, t] for t in themes)
@classmethod
- @method.cachedIn('_cache')
+ @memoize
def current_theme(cls):
theme = ThemeManager.themes().get(settings.THEME, None)
if theme is not None:
@@ -108,12 +108,12 @@ def current_theme(cls):
raise ThemeNotFoundException("Theme with id '%s' cannot be found." % settings.THEME)
@staticmethod
- @method.cachedIn('_cache')
+ @memoize
def theme_path(template):
return path(ThemeManager.current_theme().template_root) / template
@staticmethod
- @method.cachedIn('_cache')
+ @memoize
def theme(id):
if id not in ThemeManager.themes():
raise ThemeNotFoundException("Theme with id '%s' cannot be found." % settings.THEME)
View
2  requirements.txt
@@ -4,11 +4,9 @@ pyYAML>=3.10
flufl.enum>=3.3.1
translitcodec>=0.2
jinja2>=2.6
-compressinja>=0.0.1
pygments>=1.4
html5lib>=0.90
python-dateutil>=2.1
-zope.cachedescriptors>=3.5.1
humanize>=0.2
bottle>=0.10.9
pytz>=2011k
Please sign in to comment.
Something went wrong with that request. Please try again.