bug fixes for import, i18n, actions

git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@2437 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
helmutm 2008-03-06 11:28:49 +00:00
parent 86d7781725
commit 32ef1a067d
9 changed files with 34 additions and 22 deletions

View file

@ -68,7 +68,8 @@ class DialogAction(Action):
if self.fixedType: if self.fixedType:
urlParams['fixed_type'] = 'yes' urlParams['fixed_type'] = 'yes'
urlParams.update(self.addParams) urlParams.update(self.addParams)
url = self.page.virtualTargetUrlWithSkin #url = self.page.virtualTargetUrlWithSkin
url = self.page.virtualTargetUrl
return self.jsOnClick % (self.dialogName, url, self.viewName, return self.jsOnClick % (self.dialogName, url, self.viewName,
urlencode(urlParams)) urlencode(urlParams))

View file

@ -25,10 +25,11 @@ $Id$
from zope.interface import Interface, Attribute from zope.interface import Interface, Attribute
from zope import interface, component, schema from zope import interface, component, schema
from loops.interfaces import IConceptSchema
from loops.util import _ from loops.util import _
class IClassifier(Interface): class IClassifier(IConceptSchema):
""" An object that is able to analyze a resource and identify the """ An object that is able to analyze a resource and identify the
concepts to assign. concepts to assign.
""" """

2
external/README.txt vendored
View file

@ -82,7 +82,7 @@ Writing object information to the external storage
>>> writer = PyWriter() >>> writer = PyWriter()
>>> writer.write(elements, output) >>> writer.write(elements, output)
>>> print output.getvalue() >>> 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', type(u'query', u'Query', options=u'', typeInterface='loops.query.IQueryConcept',
viewName=u'')... viewName=u'')...
concept(u'myquery', u'My Query', u'query', options=u'', viewName='mystuff.html')... concept(u'myquery', u'My Query', u'query', options=u'', viewName='mystuff.html')...

3
external/base.py vendored
View file

@ -125,7 +125,8 @@ class Extractor(Base):
schema = schemaFactory(ti, manager=self) #, request=self.request) schema = schemaFactory(ti, manager=self) #, request=self.request)
instance = IInstance(aObj) instance = IInstance(aObj)
instance.template = schema 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='export')
data = instance.applyTemplate(mode='edit') data = instance.applyTemplate(mode='edit')
if 'title' in data: if 'title' in data:

18
external/element.py vendored
View file

@ -25,7 +25,7 @@ $Id$
from zope.cachedescriptors.property import Lazy from zope.cachedescriptors.property import Lazy
from zope.dottedname.resolve import resolve 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 zope.traversing.api import getName, traverse
from loops.external.interfaces import IElement from loops.external.interfaces import IElement
@ -68,17 +68,18 @@ class TypeElement(ConceptElement):
def __init__(self, name, title, *args, **kw): def __init__(self, name, title, *args, **kw):
super(TypeElement, self).__init__(name, title, *args, **kw) super(TypeElement, self).__init__(name, title, *args, **kw)
ti = self['typeInterface'] ti = self.get('typeInterface')
if ti: if ti:
self['typeInterface'] = '.'.join((ti.__module__, ti.__name__)) if not isinstance(ti, basestring):
else: self['typeInterface'] = '.'.join((ti.__module__, ti.__name__))
del self['typeInterface']
def __call__(self, loader): def __call__(self, loader):
kw = dict((k, v) for k, v in self.items() kw = dict((k, v) for k, v in self.items()
if k not in ('name', 'title', 'type', 'typeInterface')) if k not in ('name', 'title', 'type', 'typeInterface'))
kw['typeInterface'] = resolve(self['typeInterface']) ti = self.get('typeInterface')
loader.addConcept(self['name'], self['title'], 'type', **kw) if ti:
kw['typeInterface'] = resolve(ti)
loader.addConcept(self['name'], self['title'], loader.typeConcept, **kw)
class ChildElement(Element): class ChildElement(Element):
@ -113,7 +114,8 @@ class NodeElement(Element):
if k not in self.posArgs) if k not in self.posArgs)
node = loader.addNode(self['name'], self['title'], cont, type, **kw) node = loader.addNode(self['name'], self['title'], cont, type, **kw)
if target is not None: if target is not None:
node.target = traverse(loader.context, target) targetObject = traverse(loader.context, target, None)
node.target = targetObject
# not yet implemented # not yet implemented

16
external/pyfunc.py vendored
View file

@ -30,18 +30,22 @@ from loops.external.interfaces import IReader, IWriter
from loops.external.element import elementTypes from loops.external.element import elementTypes
class PyReader(dict): class PyReader(object):
implements(IReader) implements(IReader)
def __init__(self):
self.elements = []
def read(self, input): def read(self, input):
if not isinstance(input, str): if not isinstance(input, str):
input = input.read() input = input.read()
exec input in self proc = InputProcessor()
return self.elements exec input in proc
return proc.elements
class InputProcessor(dict):
def __init__(self):
self.elements = []
def __getitem__(self, key): def __getitem__(self, key):
def factory(*args, **kw): def factory(*args, **kw):

View file

@ -115,7 +115,7 @@ Now we are ready to enter a language-specific title.
>>> form.update() >>> form.update()
>>> topic01.title >>> 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 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. value corresponding to the language preferences that appear in the request.

View file

@ -58,8 +58,8 @@ class I18NValue(PersistentMapping):
#def __unicode__(self): #def __unicode__(self):
# return unicode(self.getDefault()) # return unicode(self.getDefault())
#def __repr__(self): def __repr__(self):
# return repr(self.getDefault()) return 'I18NValue(%r)' % dict(self)
def getI18nValue(obj, attr, langInfo=None): def getI18nValue(obj, attr, langInfo=None):
@ -115,6 +115,9 @@ class I18NAdapterBase(AdapterBase):
@Lazy @Lazy
def i18nAttributes(self): def i18nAttributes(self):
if getattr(self.context, '__parent__', None) is None:
# temporary object during creation
return []
tp = IType(self.context) tp = IType(self.context)
attrs = tp.optionsDict.get('i18nattributes', '') attrs = tp.optionsDict.get('i18nattributes', '')
return [attr.strip() for attr in attrs.split(',')] return [attr.strip() for attr in attrs.split(',')]

View file

@ -155,7 +155,7 @@ class SetupManager(object):
def assignChild(self, conceptName, childName, predicate=None): def assignChild(self, conceptName, childName, predicate=None):
if predicate is None: if predicate is None:
predicate = self.concepts.getDefaultPredicate() predicate = self.concepts.getDefaultPredicate()
if isinstance(predicate, str): if isinstance(predicate, basestring):
predicate = self.concepts[predicate] predicate = self.concepts[predicate]
concept = self.concepts[conceptName] concept = self.concepts[conceptName]
child = self.concepts[childName] child = self.concepts[childName]