get rid of some Zope 3.3 deprecation messages; and a few minor improvements
git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@1663 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
bd0fda6cb9
commit
9ddadfa7a5
4 changed files with 39 additions and 28 deletions
|
@ -41,8 +41,8 @@ class LoopsSessionCredentialsPlugin(SessionCredentialsPlugin):
|
||||||
if not IHTTPRequest.providedBy(request):
|
if not IHTTPRequest.providedBy(request):
|
||||||
return False
|
return False
|
||||||
site = hooks.getSite()
|
site = hooks.getSite()
|
||||||
#camefrom = request.getURL() # wrong when object is not viewable
|
camefrom = request.getURL() # wrong when object is not viewable
|
||||||
camefrom = request.getApplicationURL() + request['PATH_INFO']
|
#camefrom = request.getApplicationURL() + request['PATH_INFO']
|
||||||
if 'login' in camefrom:
|
if 'login' in camefrom:
|
||||||
camefrom = '/'.join(camefrom.split('/')[:-1])
|
camefrom = '/'.join(camefrom.split('/')[:-1])
|
||||||
url = '%s/@@%s?%s' % (zapi.absoluteURL(site, request),
|
url = '%s/@@%s?%s' % (zapi.absoluteURL(site, request),
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
<metal:block define-macro="page"><metal:block define-slot="doctype"><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"></metal:block>
|
<metal:block define-macro="page"
|
||||||
|
tal:define="dummy view/setupSubviews"
|
||||||
|
tal:condition="view/update"><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"
|
||||||
i18n:domain="zope"
|
i18n:domain="zope"
|
||||||
tal:define="controller nocall:view/@@controller;
|
tal:define="controller nocall:view/@@controller;
|
||||||
resourceBase controller/resourceBase;
|
resourceBase controller/resourceBase;
|
||||||
dummy view/update;
|
|
||||||
body view/pageBody">
|
body view/pageBody">
|
||||||
|
|
||||||
<head metal:define-macro="head">
|
<head metal:define-macro="head">
|
||||||
|
|
|
@ -57,7 +57,7 @@ class GenericView(object):
|
||||||
# make the (one and only controller) available via the request
|
# make the (one and only controller) available via the request
|
||||||
viewAnnotations = self.request.annotations.setdefault('cybertools.browser', {})
|
viewAnnotations = self.request.annotations.setdefault('cybertools.browser', {})
|
||||||
viewAnnotations['controller'] = controller
|
viewAnnotations['controller'] = controller
|
||||||
if getattr(controller, 'skinName', None):
|
if getattr(controller, 'skinName', None) and controller.skinName.value:
|
||||||
self.setSkin(controller.skinName.value)
|
self.setSkin(controller.skinName.value)
|
||||||
controller.skin = self.skin
|
controller.skin = self.skin
|
||||||
# this is the place to register special macros with the controller:
|
# this is the place to register special macros with the controller:
|
||||||
|
@ -75,8 +75,12 @@ class GenericView(object):
|
||||||
# self.setupController()
|
# self.setupController()
|
||||||
|
|
||||||
def __call__(self, *args, **kw):
|
def __call__(self, *args, **kw):
|
||||||
|
# this is useful for a top-level page only
|
||||||
return self.index(*args, **kw)
|
return self.index(*args, **kw)
|
||||||
|
|
||||||
|
def setupSubviews(self):
|
||||||
|
pass
|
||||||
|
|
||||||
#def render(self, *args, **kw):
|
#def render(self, *args, **kw):
|
||||||
# return self.index(*args, **kw)
|
# return self.index(*args, **kw)
|
||||||
|
|
||||||
|
|
|
@ -25,17 +25,18 @@ $Id$
|
||||||
from persistent import Persistent
|
from persistent import Persistent
|
||||||
from persistent.interfaces import IPersistent
|
from persistent.interfaces import IPersistent
|
||||||
from zope import component
|
from zope import component
|
||||||
|
from zope.component import adapts
|
||||||
from zope.interface import Interface, Attribute, implements
|
from zope.interface import Interface, Attribute, implements
|
||||||
from zope.app import zapi
|
from zope.app.catalog.catalog import Catalog, ResultSet
|
||||||
from zope.app.catalog.catalog import Catalog
|
|
||||||
from zope.app.catalog.field import FieldIndex
|
from zope.app.catalog.field import FieldIndex
|
||||||
from zope.app.intid.interfaces import IIntIds
|
from zope.app.intid.interfaces import IIntIds
|
||||||
from zope.location.interfaces import ILocation
|
from zope.location.interfaces import ILocation
|
||||||
from zope.event import notify
|
from zope.event import notify
|
||||||
from zope.component.interfaces import ObjectEvent
|
from zope.component.interfaces import ObjectEvent
|
||||||
from zope.security.proxy import removeSecurityProxy
|
from zope.security.proxy import removeSecurityProxy
|
||||||
|
from zope.traversing.api import getName, getParent
|
||||||
|
|
||||||
from interfaces import IRelationRegistry, IRelationInvalidatedEvent
|
from interfaces import IRelationRegistry, IRelationInvalidatedEvent, IRelation
|
||||||
|
|
||||||
|
|
||||||
class DummyRelationRegistry(object):
|
class DummyRelationRegistry(object):
|
||||||
|
@ -123,25 +124,35 @@ class RelationRegistry(Catalog):
|
||||||
if getattr(relation, '__parent__', None) is None:
|
if getattr(relation, '__parent__', None) is None:
|
||||||
# Allow the IntIds utility to get a DB connection:
|
# Allow the IntIds utility to get a DB connection:
|
||||||
relation.__parent__ = self
|
relation.__parent__ = self
|
||||||
self.index_doc(zapi.getUtility(IIntIds).register(relation), relation)
|
self.index_doc(component.getUtility(IIntIds).register(relation), relation)
|
||||||
|
|
||||||
def unregister(self, relation):
|
def unregister(self, relation):
|
||||||
self.unindex_doc(zapi.getUtility(IIntIds).getId(relation))
|
self.unindex_doc(component.getUtility(IIntIds).getId(relation))
|
||||||
notify(RelationInvalidatedEvent(relation))
|
notify(RelationInvalidatedEvent(relation))
|
||||||
|
|
||||||
def getUniqueIdForObject(self, obj):
|
def getUniqueIdForObject(self, obj):
|
||||||
if obj == '*': # wild card
|
if obj == '*': # wild card
|
||||||
return '*'
|
return '*'
|
||||||
return zapi.getUtility(IIntIds).queryId(obj)
|
return component.getUtility(IIntIds).queryId(obj)
|
||||||
|
|
||||||
|
def apply(self, criteria):
|
||||||
|
for k in criteria:
|
||||||
|
# set min, max
|
||||||
|
value = criteria[k]
|
||||||
|
if k == 'relationship' and value.endswith('*'):
|
||||||
|
criteria[k] = (value[:-1], value[:-1] + '\x7f')
|
||||||
|
else:
|
||||||
|
criteria[k] = (value, value)
|
||||||
|
return super(RelationRegistry, self).apply(criteria)
|
||||||
|
|
||||||
def query(self, example=None, **kw):
|
def query(self, example=None, **kw):
|
||||||
intIds = zapi.getUtility(IIntIds)
|
intids = component.getUtility(IIntIds)
|
||||||
criteria = {}
|
criteria = {}
|
||||||
if example is not None:
|
if example is not None:
|
||||||
for attr in ('first', 'second', 'third',):
|
for attr in ('first', 'second', 'third',):
|
||||||
value = getattr(example, attr, None)
|
value = getattr(example, attr, None)
|
||||||
if value is not None:
|
if value is not None:
|
||||||
criteria[attr] = intIds.getId(value)
|
criteria[attr] = intids.getId(value)
|
||||||
pn = example.getPredicateName()
|
pn = example.getPredicateName()
|
||||||
if pn:
|
if pn:
|
||||||
criteria['relationship'] = pn
|
criteria['relationship'] = pn
|
||||||
|
@ -150,15 +161,9 @@ class RelationRegistry(Catalog):
|
||||||
if k == 'relationship':
|
if k == 'relationship':
|
||||||
criteria[k] = kw[k].getPredicateName()
|
criteria[k] = kw[k].getPredicateName()
|
||||||
else:
|
else:
|
||||||
criteria[k] = intIds.getId(kw[k])
|
criteria[k] = intids.getId(kw[k])
|
||||||
for k in criteria:
|
results = self.apply(criteria)
|
||||||
# set min, max
|
return ResultSet(results, intids)
|
||||||
value = criteria[k]
|
|
||||||
if k == 'relationship' and value.endswith('*'):
|
|
||||||
criteria[k] = (value[:-1], value[:-1] + '\x7f')
|
|
||||||
else:
|
|
||||||
criteria[k] = (value, value)
|
|
||||||
return self.searchResults(**criteria)
|
|
||||||
|
|
||||||
|
|
||||||
class IIndexableRelation(Interface):
|
class IIndexableRelation(Interface):
|
||||||
|
@ -173,6 +178,7 @@ class IndexableRelationAdapter(object):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
implements(IIndexableRelation)
|
implements(IIndexableRelation)
|
||||||
|
adapts(IRelation)
|
||||||
|
|
||||||
def __init__(self, context):
|
def __init__(self, context):
|
||||||
self.context = context
|
self.context = context
|
||||||
|
@ -184,7 +190,7 @@ class IndexableRelationAdapter(object):
|
||||||
def __getattr__(self, attr):
|
def __getattr__(self, attr):
|
||||||
value = getattr(self.context, attr)
|
value = getattr(self.context, attr)
|
||||||
if IPersistent.providedBy(value):
|
if IPersistent.providedBy(value):
|
||||||
return zapi.getUtility(IIntIds).getId(value)
|
return component.getUtility(IIntIds).getId(value)
|
||||||
else:
|
else:
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
@ -226,7 +232,7 @@ def getRelationSingle(obj=None, relationship=None, forSecond=True):
|
||||||
return None
|
return None
|
||||||
if len(rels) > 1:
|
if len(rels) > 1:
|
||||||
raise ValueError('Multiple hits when only one relation expected: '
|
raise ValueError('Multiple hits when only one relation expected: '
|
||||||
'%s, relationship: %s' % (zapi.getName(obj),
|
'%s, relationship: %s' % (getName(obj),
|
||||||
relationship.getPredicateName()))
|
relationship.getPredicateName()))
|
||||||
return list(rels)[0]
|
return list(rels)[0]
|
||||||
|
|
||||||
|
@ -237,7 +243,7 @@ def setRelationSingle(relation, forSecond=True):
|
||||||
"""
|
"""
|
||||||
first = relation.first
|
first = relation.first
|
||||||
second = relation.second
|
second = relation.second
|
||||||
registry = zapi.getUtility(IRelationRegistry)
|
registry = component.getUtility(IRelationRegistry)
|
||||||
if forSecond:
|
if forSecond:
|
||||||
rels = list(registry.query(second=second, relationship=relation))
|
rels = list(registry.query(second=second, relationship=relation))
|
||||||
else:
|
else:
|
||||||
|
@ -261,7 +267,7 @@ def invalidateRelations(context, event):
|
||||||
# if not IRelatable.providedBy(event.object):
|
# if not IRelatable.providedBy(event.object):
|
||||||
# return
|
# return
|
||||||
relations = []
|
relations = []
|
||||||
registries = zapi.getAllUtilitiesRegisteredFor(IRelationRegistry)
|
registries = component.getAllUtilitiesRegisteredFor(IRelationRegistry)
|
||||||
for registry in registries:
|
for registry in registries:
|
||||||
for attr in ('first', 'second', 'third'):
|
for attr in ('first', 'second', 'third'):
|
||||||
try:
|
try:
|
||||||
|
@ -277,10 +283,10 @@ def removeRelation(context, event):
|
||||||
from its container (if appropriate) and the IntIds utility.
|
from its container (if appropriate) and the IntIds utility.
|
||||||
"""
|
"""
|
||||||
if ILocation.providedBy(context):
|
if ILocation.providedBy(context):
|
||||||
parent = zapi.getParent(context)
|
parent = getParent(context)
|
||||||
if parent is not None:
|
if parent is not None:
|
||||||
del parent[context]
|
del parent[context]
|
||||||
intids = zapi.getUtility(IIntIds)
|
intids = component.getUtility(IIntIds)
|
||||||
intids.unregister(context)
|
intids.unregister(context)
|
||||||
|
|
||||||
def setupIndexes(context, event):
|
def setupIndexes(context, event):
|
||||||
|
|
Loading…
Add table
Reference in a new issue