def __call__(self, context, location): key = stringKey(context) for container in self.containers: if IQueryContent.providedBy(container): parent = container.__parent__ container = container.query(location) if parent is not None: container.__parent__ = parent if key in container: return LocationProxy(context, container, key) raise LocationError(key)
def publishTraverse(self, request, name): # this is the primary condition; traverse to ``name`` by # looking up methods on this class try: method = getattr(self.context, "get_%s" % name) except AttributeError: # fall back to default traversal (view lookup) def method(): return super(SchedulingContextTraverser, self).publishTraverse(request, name) obj = method() assert ILocation.providedBy(obj), obj log.debug("SchedulingContextTraverser.publishTraverse: " \ "self=%s context=%s name=%s obj=%s" % (self, self.context, name, obj)) return ProxyFactory( LocationProxy(removeSecurityProxy(obj), container=self.context, name=name))
def get_sittings(self, start_date=None, end_date=None): try: sittings = self.sittings_container except (AttributeError, ): # e.g. ministry has no sittings attribute return {} # !+ should be a bungeni.models.domain.ManagedContainer # !+ could add sittings to a ministry # could not have calendar appear for ministries if start_date is None and end_date is None: return sittings assert start_date and end_date unproxied = removeSecurityProxy(sittings) unproxied.subset_query = sql.and_( unproxied.subset_query, domain.Sitting.start_date.between(format_date(start_date), format_date(end_date))) unproxied.__parent__ = ProxyFactory( LocationProxy(unproxied.__parent__, container=self, name="group")) return unproxied
def get_sittings(self, start_date=None, end_date=None): sittings = self.get_group().sittings if start_date is None and end_date is None: return sittings assert start_date and end_date unproxied = removeSecurityProxy(sittings) session = Session() unproxied.subset_query = sql.and_( unproxied.subset_query, GroupSitting.start_date.between( format_date(start_date), format_date(end_date)) ) unproxied.__parent__ = ProxyFactory(LocationProxy( unproxied.__parent__, container=self, name="group")) # r_sittings = [] return sittings