Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@
from setuptools import setup

install_requires = [
'future'
'future',
'testtools',
'unittest2'
]

if (sys.version_info < (3,0)):
# has a different name if supporting Python3
install_requires.append('python-ntlm')
install_requires.append("repoze.lru")
else:
install_requires.append('python-ntlm3')

Expand Down Expand Up @@ -59,6 +62,7 @@

tests_require = [
'testtools',
'repoze.lru',
'unittest2' # so testtools tests are auto-discovered
],
test_suite = "tests",
Expand Down
2 changes: 1 addition & 1 deletion tests/creation_tests.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from testtools import TestCase
#from testtools import TestCase

import v1pysdk
from .common_test_server import PublicTestServerConnection
Expand Down
25 changes: 0 additions & 25 deletions v1pysdk/cache_decorator.py

This file was deleted.

22 changes: 13 additions & 9 deletions v1pysdk/v1meta.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import sys

if (sys.version_info < (3,0)):
from repoze.lru import lru_cache

else:
from functools import lru_cache
try:
from xml.etree import ElementTree
except ImportError:
from elementtree import ElementTree

from .client import *
from .base_asset import BaseAsset
from .cache_decorator import memoized
from .special_class_methods import special_classes
from .none_deref import NoneDeref
from .string_utils import split_attribute
Expand All @@ -17,7 +21,6 @@ def __init__(self, *args, **kw):
self.server = V1Server(*args, **kw)
self.global_cache = {}
self.dirtylist = []
self._memoized_data = {}

def __getattr__(self, attr):
"Dynamically build asset type classes when someone tries to get attrs "
Expand All @@ -28,14 +31,15 @@ def __enter__(self):
return self

def __exit__(self, *args, **kw):
self.clear_memoized_cache()
if (sys.version_info > (3, 0)):
self.asset_class.cache_clear()
else:
self.assert_class.clear()

self.commit()

def clear_memoized_cache(self):
"""Clears the memoization cache produced by the @memoized decorator"""
self._memoized_data={}

@memoized # from .cache_decorator
@lru_cache(maxsize=512)
def asset_class(self, asset_type_name):
xmldata = self.server.get_meta_xml(asset_type_name)
class_members = {
Expand Down Expand Up @@ -93,15 +97,15 @@ def add_to_dirty_list(self, asset_instance):
# are a few triggers to do this, it's best to clear our memoization cache for
# query responses as soon as we have something that can get flushed rather than
# waiting for it to actually be flushed
self.clear_memoized_cache()
self.asset_class.cache_clear()
self.dirtylist.append(asset_instance)

def commit(self):
errors = []
# we're flushing changes, make sure our memoization cache is cleared so the updates
# are re-queried
if self.dirtylist:
self.clear_memoized_cache()
self.asset_class.cache_clear()
for asset in self.dirtylist:
try:
asset._v1_commit()
Expand Down