Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Activity Date: attr_active_end ends with the given date at 00:00:00 #3

Open
drfho opened this issue Feb 4, 2023 · 0 comments
Open

Comments

@drfho
Copy link
Contributor

drfho commented Feb 4, 2023

The latest Change (12/2021) on _objattr.isActive()

ZMS3/_objattrs.py

Lines 748 to 794 in 95f5905

# --------------------------------------------------------------------------
# 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

attr_active_end

attr_active_en_oldd

n

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant