fix datatable source list; add generic IOptions adapter
This commit is contained in:
parent
0915d04e30
commit
4a18c42283
3 changed files with 17 additions and 5 deletions
|
@ -1,5 +1,5 @@
|
||||||
#
|
#
|
||||||
# Copyright (c) 2008 Helmut Merz helmutm@cy55.de
|
# Copyright (c) 2016 Helmut Merz helmutm@cy55.de
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
@ -18,8 +18,6 @@
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Adapters and others classes for analyzing resources.
|
Adapters and others classes for analyzing resources.
|
||||||
|
|
||||||
$Id$
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
@ -33,6 +31,7 @@ from cybertools.meta.config import GlobalOptions as BaseGlobalOptions
|
||||||
from cybertools.meta.interfaces import IOptions
|
from cybertools.meta.interfaces import IOptions
|
||||||
from cybertools.meta.namespace import Executor, ExecutionError
|
from cybertools.meta.namespace import Executor, ExecutionError
|
||||||
from cybertools.typology.interfaces import IType
|
from cybertools.typology.interfaces import IType
|
||||||
|
from loops.common import AdapterBase
|
||||||
from loops.interfaces import ILoops, ILoopsObject, ITypeConcept, IPredicate
|
from loops.interfaces import ILoops, ILoopsObject, ITypeConcept, IPredicate
|
||||||
#from loops.query import IQueryConcept
|
#from loops.query import IQueryConcept
|
||||||
from loops.expert.concept import IQueryConcept
|
from loops.expert.concept import IQueryConcept
|
||||||
|
@ -73,8 +72,8 @@ class LoopsOptions(Options):
|
||||||
|
|
||||||
def parseContextOptions(self):
|
def parseContextOptions(self):
|
||||||
def result():
|
def result():
|
||||||
options = getattr(self.context, 'options', [])
|
options = getattr(self.context, 'options', None) or []
|
||||||
for opt in options:
|
for opt in options:
|
||||||
parts = opt.split(':', 1)
|
parts = opt.split(':', 1)
|
||||||
key = parts[0].strip()
|
key = parts[0].strip()
|
||||||
if len(parts) == 1:
|
if len(parts) == 1:
|
||||||
|
@ -128,6 +127,11 @@ class PredicateOptions(LoopsOptions):
|
||||||
adapts(IPredicate)
|
adapts(IPredicate)
|
||||||
|
|
||||||
|
|
||||||
|
class ConceptAdapterOptions(LoopsOptions):
|
||||||
|
|
||||||
|
adapts(AdapterBase)
|
||||||
|
|
||||||
|
|
||||||
class DummyOptions(Options):
|
class DummyOptions(Options):
|
||||||
|
|
||||||
def __getitem__(self, key):
|
def __getitem__(self, key):
|
||||||
|
|
|
@ -27,6 +27,11 @@
|
||||||
<allow interface="cybertools.meta.interfaces.IOptions" />
|
<allow interface="cybertools.meta.interfaces.IOptions" />
|
||||||
</zope:class>
|
</zope:class>
|
||||||
|
|
||||||
|
<zope:adapter factory="loops.config.base.ConceptAdapterOptions" trusted="True" />
|
||||||
|
<zope:class class="loops.config.base.ConceptAdapterOptions">
|
||||||
|
<allow interface="cybertools.meta.interfaces.IOptions" />
|
||||||
|
</zope:class>
|
||||||
|
|
||||||
<!-- backward compatibility -->
|
<!-- backward compatibility -->
|
||||||
<zope:adapter factory="loops.config.base.QueryOptions" trusted="True"
|
<zope:adapter factory="loops.config.base.QueryOptions" trusted="True"
|
||||||
for="loops.query.IQueryConcept" />
|
for="loops.query.IQueryConcept" />
|
||||||
|
|
3
table.py
3
table.py
|
@ -142,5 +142,8 @@ class DataTableSourceList(object):
|
||||||
for k, v in self.context.data.items()]
|
for k, v in self.context.data.items()]
|
||||||
return iter(sorted(items, key=lambda x: x[1]))
|
return iter(sorted(items, key=lambda x: x[1]))
|
||||||
|
|
||||||
|
def __contains__(self, value):
|
||||||
|
return value in self.context.data
|
||||||
|
|
||||||
def __len__(self):
|
def __len__(self):
|
||||||
return len(self.context.data)
|
return len(self.context.data)
|
||||||
|
|
Loading…
Add table
Reference in a new issue