The latest Change (12/2021) on _objattr.isActive()
|
# -------------------------------------------------------------------------- |
|
# ObjAttrs.isActive: |
|
# -------------------------------------------------------------------------- |
|
def isActive(self, REQUEST): |
|
b = True |
|
if self.getType()=='ZMSRecordSet': |
|
return b |
|
v = self.attr('active') |
|
if type(v) is bool: |
|
return v |
|
v = self.attr('isActive') |
|
if type(v) is bool: |
|
b = b and v |
|
obj_vers = self.getObjVersion(REQUEST) |
|
obj_attrs = self.getObjAttrs() |
|
now = datetime.datetime.now() |
|
for key in ['active', 'attr_active_start', 'attr_active_end']: |
|
if obj_attrs.has_key(key): |
|
obj_attr = obj_attrs[key] |
|
lang = self.get_request_context(REQUEST, 'lang', self.getPrimaryLanguage()) |
|
while True: |
|
value = self._getObjAttrValue(obj_attr, obj_vers, lang) |
|
empty = False |
|
lang = self.getParentLanguage(lang) |
|
if lang is not None: |
|
empty = value is None |
|
if not empty: |
|
break |
|
# Toggle. |
|
if key == 'active': |
|
b = b and value |
|
# Start time. |
|
elif key == 'attr_active_start': |
|
if value is not None: |
|
dt = datetime.datetime.fromtimestamp(time.mktime(value)) |
|
b = b and now > dt |
|
if dt > now and self.REQUEST.get('ZMS_CACHE_EXPIRE_DATETIME', dt) >= dt: |
|
self.REQUEST.set('ZMS_CACHE_EXPIRE_DATETIME',dt) |
|
# End time. |
|
elif key == 'attr_active_end': |
|
if value is not None: |
|
dt = datetime.datetime.fromtimestamp(time.mktime(value)) |
|
b = b and dt > now |
|
if dt > now and self.REQUEST.get('ZMS_CACHE_EXPIRE_DATETIME', dt) >= dt: |
|
self.REQUEST.set('ZMS_CACHE_EXPIRE_DATETIME',dt) |
|
if not b: break |
|
return b |
was a ZMS5-backport that was introduced in 2020 to allow a
preview_time_travel to check activity-controlled content changes in time and providing a way to explicit http header cache control by the request variable
ZMS_CACHE_EXPIRE_DATETIME :
https://github.com/zms-publishing/ZMS/blob/main/docs/develop_api_exampels_en.md#4-set_response_headers_cache
According to the wishes of some extensive users the content timing (caching) should be precise in time and not just daily intervals like before:
dt.isFuture() or (dt.equalTo(dt.earliestTime()) and dt.latestTime().isFuture())
As a side effect, now, an activity-ending date has to be given cannot be given as date, exp: 01.02.2022, because this is considered as
01.02.2022 00:00:00
but as datetime. exp:
01.02.2022 23:59:59


n
The latest Change (12/2021) on _objattr.isActive()
ZMS3/_objattrs.py
Lines 748 to 794 in 95f5905
was a ZMS5-backport that was introduced in 2020 to allow a
preview_time_travelto check activity-controlled content changes in time and providing a way to explicit http header cache control by the request variableZMS_CACHE_EXPIRE_DATETIME:https://github.com/zms-publishing/ZMS/blob/main/docs/develop_api_exampels_en.md#4-set_response_headers_cache
According to the wishes of some extensive users the content timing (caching) should be precise in time and not just daily intervals like before:
As a side effect, now, an activity-ending date has to be given cannot be given as date, exp: 01.02.2022, because this is considered as
01.02.2022 00:00:00
but as datetime. exp:
01.02.2022 23:59:59
n