[CalendarServer-dev] Circular reference in 8.0 (cannot import name GroupCacherPollingWork)

Axel Rau Axel.Rau at chaos1.de
Fri May 20 03:31:20 PDT 2016


> Am 19.05.2016 um 19:54 schrieb Andre LaBranche <dre at apple.com>:
> 
> Is txdav updated?
It’s what is included in CalendarServer-8.0 (see below)

> This should work:
> 
>>>> from txdav.who.groups import GroupCacherPollingWork
>>>> GroupCacherPollingWork
> <class 'txdav.who.groups.GroupCacherPollingWork‘>
???
If I break in > txdav/caldav/datastore/sql.py(1166)Calendar()
- - -
(Pdb) l
1161 	    _supportedComponents = None
1162 	
1163 	    import pdb
1164 	    pdb.set_trace()
1165 	    
1166 ->	    _shadowProperties = tuple([PropertyName.fromString(prop) for prop in config.Sharing.Calendars.CollectionProperties.Shadowable])
1167 	    _proxyProperties = tuple([PropertyName.fromString(prop) for prop in config.Sharing.Calendars.CollectionProperties.ProxyOverride])
1168 	    _globalProperties = tuple([PropertyName.fromString(prop) for prop in config.Sharing.Calendars.CollectionProperties.Global])
- - -
I get an exception in Calendars here:
- - -
(Pdb) p config.Sharing.Calendars
*** ImportError: ImportError(‚cannot import name GroupCacherPollingWork',)
- - -
while this works:
- - -
(Pdb) p config.Sharing
*{‚Enabled': True, 'AddressBooks': *{'Groups': *{'Enabled': False}, 'CollectionProperties': *{'Shadowable': ['{urn:ietf:params:xml:ns:carddav}addressbook-description'], 'ProxyOverride': [], 'Global': []}, 'Enabled': False}, 'Calendars': *{'IgnorePerUserProperties': ['X-APPLE-STRUCTURED-LOCATION'], 'CollectionProperties': *{'Shadowable': ['{urn:ietf:params:xml:ns:caldav}calendar-description'], 'ProxyOverride': ['{urn:ietf:params:xml:ns:caldav}calendar-description', '{com.apple.ical:}calendarcolor', '{http://apple.com/ns/ical/}calendar-color', '{http://apple.com/ns/ical/}calendar-order'], 'Global': []}, 'Enabled': True, 'Groups': *{'Enabled': True, 'ReconciliationDelaySeconds': 5}}, 'AllowExternalUsers': False}
- - -

Axel

PS:

[caldav3:/] root# head -85 /usr/local/lib/python2.7/site-packages/txdav/who/groups.py
# -*- test-case-name: txdav.who.test.test_groups -*-
##
# Copyright (c) 2013-2016 Apple Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
##

"""
Group membership caching
"""

from twext.enterprise.dal.record import fromTable
from twext.enterprise.dal.syntax import Select
from twext.enterprise.jobs.workitem import AggregatedWorkItem, RegeneratingWorkItem
from twext.python.log import Logger
from twisted.internet.defer import inlineCallbacks, returnValue, succeed, \
   DeferredList
from twistedcaldav.config import config
from txdav.caldav.datastore.sql import CalendarStoreFeatures
from txdav.caldav.datastore.sql_directory import GroupAttendeeRecord
from txdav.common.datastore.sql_directory import GroupsRecord
from txdav.common.datastore.sql_tables import schema, _BIND_MODE_OWN
import datetime
import itertools
import time

log = Logger()


class GroupCacherPollingWork(
   RegeneratingWorkItem,
   fromTable(schema.GROUP_CACHER_POLLING_WORK)
):

   group = "group_cacher_polling"

   @classmethod
   def initialSchedule(cls, store, seconds):
       def _enqueue(txn):
           return GroupCacherPollingWork.reschedule(txn, seconds)

       if config.GroupCaching.Enabled:
           return store.inTransaction("GroupCacherPollingWork.initialSchedule", _enqueue)
       else:
           return succeed(None)


   def regenerateInterval(self):
       """
       Return the interval in seconds between regenerating instances.
       """
       groupCacher = getattr(self.transaction, "_groupCacher", None)
       return groupCacher.updateSeconds if groupCacher else 10


   @inlineCallbacks
   def doWork(self):

       groupCacher = getattr(self.transaction, "_groupCacher", None)
       if groupCacher is not None:

           startTime = time.time()
           try:
               yield groupCacher.update(self.transaction)
           except Exception, e:
               log.error(
                   "Failed to update new group membership cache ({error})",
                   error=e
               )
           endTime = time.time()
           log.debug(
               "GroupCacher polling took {duration:0.2f} seconds",
               duration=(endTime - startTime)
           )


---
PGP-Key:29E99DD6  ☀  computing @ chaos claudius



More information about the calendarserver-dev mailing list