diff --git a/browser/action.py b/browser/action.py index 7271ebc..710e124 100644 --- a/browser/action.py +++ b/browser/action.py @@ -68,7 +68,8 @@ class DialogAction(Action): if self.fixedType: urlParams['fixed_type'] = 'yes' urlParams.update(self.addParams) - url = self.page.virtualTargetUrlWithSkin + #url = self.page.virtualTargetUrlWithSkin + url = self.page.virtualTargetUrl return self.jsOnClick % (self.dialogName, url, self.viewName, urlencode(urlParams)) diff --git a/classifier/interfaces.py b/classifier/interfaces.py index d653a9b..b2a2fc0 100644 --- a/classifier/interfaces.py +++ b/classifier/interfaces.py @@ -25,10 +25,11 @@ $Id$ from zope.interface import Interface, Attribute from zope import interface, component, schema +from loops.interfaces import IConceptSchema from loops.util import _ -class IClassifier(Interface): +class IClassifier(IConceptSchema): """ An object that is able to analyze a resource and identify the concepts to assign. """ diff --git a/external/README.txt b/external/README.txt index c4a7761..280d598 100644 --- a/external/README.txt +++ b/external/README.txt @@ -82,7 +82,7 @@ Writing object information to the external storage >>> writer = PyWriter() >>> writer.write(elements, output) >>> print output.getvalue() - type(u'customer', u'Customer', options=u'', viewName=u'')... + type(u'customer', u'Customer', options=u'', typeInterface=u'', viewName=u'')... type(u'query', u'Query', options=u'', typeInterface='loops.query.IQueryConcept', viewName=u'')... concept(u'myquery', u'My Query', u'query', options=u'', viewName='mystuff.html')... diff --git a/external/base.py b/external/base.py index b8dec5e..ffb01e3 100644 --- a/external/base.py +++ b/external/base.py @@ -125,7 +125,8 @@ class Extractor(Base): schema = schemaFactory(ti, manager=self) #, request=self.request) instance = IInstance(aObj) instance.template = schema - # TODO: use ``_not_exportable`` attribute of adapter to control export + # TODO: use ``_not_exportable`` attribute of adapter to control export; + # this should also convert object attributes like e.g. typeInterface #data = instance.applyTemplate(mode='export') data = instance.applyTemplate(mode='edit') if 'title' in data: diff --git a/external/element.py b/external/element.py index 25f7ffb..afbc3f5 100644 --- a/external/element.py +++ b/external/element.py @@ -25,7 +25,7 @@ $Id$ from zope.cachedescriptors.property import Lazy from zope.dottedname.resolve import resolve -from zope.interface import implements +from zope.interface import Interface, implements from zope.traversing.api import getName, traverse from loops.external.interfaces import IElement @@ -68,17 +68,18 @@ class TypeElement(ConceptElement): def __init__(self, name, title, *args, **kw): super(TypeElement, self).__init__(name, title, *args, **kw) - ti = self['typeInterface'] + ti = self.get('typeInterface') if ti: - self['typeInterface'] = '.'.join((ti.__module__, ti.__name__)) - else: - del self['typeInterface'] + if not isinstance(ti, basestring): + self['typeInterface'] = '.'.join((ti.__module__, ti.__name__)) def __call__(self, loader): kw = dict((k, v) for k, v in self.items() if k not in ('name', 'title', 'type', 'typeInterface')) - kw['typeInterface'] = resolve(self['typeInterface']) - loader.addConcept(self['name'], self['title'], 'type', **kw) + ti = self.get('typeInterface') + if ti: + kw['typeInterface'] = resolve(ti) + loader.addConcept(self['name'], self['title'], loader.typeConcept, **kw) class ChildElement(Element): @@ -113,7 +114,8 @@ class NodeElement(Element): if k not in self.posArgs) node = loader.addNode(self['name'], self['title'], cont, type, **kw) if target is not None: - node.target = traverse(loader.context, target) + targetObject = traverse(loader.context, target, None) + node.target = targetObject # not yet implemented diff --git a/external/pyfunc.py b/external/pyfunc.py index 503af46..000e4a4 100644 --- a/external/pyfunc.py +++ b/external/pyfunc.py @@ -30,18 +30,22 @@ from loops.external.interfaces import IReader, IWriter from loops.external.element import elementTypes -class PyReader(dict): +class PyReader(object): implements(IReader) - def __init__(self): - self.elements = [] - def read(self, input): if not isinstance(input, str): input = input.read() - exec input in self - return self.elements + proc = InputProcessor() + exec input in proc + return proc.elements + + +class InputProcessor(dict): + + def __init__(self): + self.elements = [] def __getitem__(self, key): def factory(*args, **kw): diff --git a/i18n/README.txt b/i18n/README.txt index 4104537..44b8b98 100644 --- a/i18n/README.txt +++ b/i18n/README.txt @@ -115,7 +115,7 @@ Now we are ready to enter a language-specific title. >>> form.update() >>> topic01.title - {'en': u'loops for Zope 3', 'it': u'loops per Zope 3'} + I18NValue({'en': u'loops for Zope 3', 'it': u'loops per Zope 3'}) If we access an i18n attribute via a view that is i18n-aware we get the value corresponding to the language preferences that appear in the request. diff --git a/i18n/common.py b/i18n/common.py index 8e608bb..e7b2912 100644 --- a/i18n/common.py +++ b/i18n/common.py @@ -58,8 +58,8 @@ class I18NValue(PersistentMapping): #def __unicode__(self): # return unicode(self.getDefault()) - #def __repr__(self): - # return repr(self.getDefault()) + def __repr__(self): + return 'I18NValue(%r)' % dict(self) def getI18nValue(obj, attr, langInfo=None): @@ -115,6 +115,9 @@ class I18NAdapterBase(AdapterBase): @Lazy def i18nAttributes(self): + if getattr(self.context, '__parent__', None) is None: + # temporary object during creation + return [] tp = IType(self.context) attrs = tp.optionsDict.get('i18nattributes', '') return [attr.strip() for attr in attrs.split(',')] diff --git a/setup.py b/setup.py index 0054cd7..33b1355 100644 --- a/setup.py +++ b/setup.py @@ -155,7 +155,7 @@ class SetupManager(object): def assignChild(self, conceptName, childName, predicate=None): if predicate is None: predicate = self.concepts.getDefaultPredicate() - if isinstance(predicate, str): + if isinstance(predicate, basestring): predicate = self.concepts[predicate] concept = self.concepts[conceptName] child = self.concepts[childName]