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:
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))

View file

@ -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.
"""

2
external/README.txt vendored
View file

@ -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')...

3
external/base.py vendored
View file

@ -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:

18
external/element.py vendored
View file

@ -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

16
external/pyfunc.py vendored
View file

@ -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):

View file

@ -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.

View file

@ -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(',')]

View file

@ -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]