"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/App/Common.py" between
Zope-5.1.2.tar.gz and Zope-5.2.tar.gz

About: Zope Z Object Publishing Environment - web application platform used for building content management systems, intranets, portals, and custom applications.

Common.py  (Zope-5.1.2):Common.py  (Zope-5.2)
skipping to change at line 17 skipping to change at line 17
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
"""Commonly used utility functions.""" """Commonly used utility functions."""
import os import os
import sys import sys
import time
# BBB
from os.path import realpath # NOQA
from Acquisition import aq_base from Acquisition import aq_base
from Acquisition import aq_parent from Acquisition import aq_parent
from zope.deferredimport import deprecated
attrget = getattr deprecated(
'Please import from zope.datetime.'
' This backwards compatibility import will go away in Zope 6.',
weekday_abbr='zope.datetime:weekday_abbr',
weekday_full='zope.datetime:weekday_full',
monthname='zope.datetime:monthname',
iso8601_date='zope.datetime:iso8601_date',
rfc850_date='zope.datetime:rfc850_date',
rfc1123_date='zope.datetime:rfc1123_date',
)
deprecated(
'Please import from os.path.'
' This backwards compatibility import will go away in Zope 6.',
realpath='os.path:realpath',
)
deprecated(
'Please import time directly.'
' This backwards compatibility import will go away in Zope 6.',
time='time',
)
# These are needed because the various date formats below must attrget = getattr
# be in english per the RFCs. That means we can't use strftime,
# which is affected by different locale settings.
weekday_abbr = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
weekday_full = ['Monday', 'Tuesday', 'Wednesday', 'Thursday',
'Friday', 'Saturday', 'Sunday']
monthname = [None, 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
def iso8601_date(ts=None):
# Return an ISO 8601 formatted date string, required
# for certain DAV properties.
# '2000-11-10T16:21:09-08:00
if ts is None:
ts = time.time()
return time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime(ts))
def rfc850_date(ts=None):
# Return an HTTP-date formatted date string.
# 'Friday, 10-Nov-00 16:21:09 GMT'
if ts is None:
ts = time.time()
year, month, day, hh, mm, ss, wd, y, z = time.gmtime(ts)
return "%s, %02d-%3s-%2s %02d:%02d:%02d GMT" % (
weekday_full[wd],
day, monthname[month],
str(year)[2:],
hh, mm, ss)
def rfc1123_date(ts=None):
# Return an RFC 1123 format date string, required for
# use in HTTP Date headers per the HTTP 1.1 spec.
# 'Fri, 10 Nov 2000 16:21:09 GMT'
if ts is None:
ts = time.time()
year, month, day, hh, mm, ss, wd, y, z = time.gmtime(ts)
return "%s, %02d %3s %4d %02d:%02d:%02d GMT" % (
weekday_abbr[wd],
day, monthname[month],
year,
hh, mm, ss)
def absattr(attr, callable=callable): def absattr(attr, callable=callable):
# Return the absolute value of an attribute, # Return the absolute value of an attribute,
# calling the attr if it is callable. # calling the attr if it is callable.
if callable(attr): if callable(attr):
return attr() return attr()
return attr return attr
def is_acquired(ob, hasattr=hasattr, aq_base=aq_base, absattr=absattr): def is_acquired(ob, hasattr=hasattr, aq_base=aq_base, absattr=absattr):
# Return true if this object is not considered to be # Return true if this object is not considered to be
# a direct subobject of its acquisition parent # a direct subobject of its acquisition parent
# Note that this method is misnamed since parents can (and do) # Note that this method is misnamed since parents can (and do)
# spoof it. It is not a true measure of whether something is # spoof it. It is not a true measure of whether something is
# acquired, it relies on the parent's parent-ness exclusively # acquired, it relies on the parent's parent-ness exclusively
import warnings import warnings
warnings.warn( warnings.warn(
"The function `is_acquired` is deprecated " "The function `is_acquired` is deprecated "
"and will be removed in future.", "and will be removed in Zope 6.",
DeprecationWarning) DeprecationWarning)
if not hasattr(ob, '__parent__'): if not hasattr(ob, '__parent__'):
# We can't be acquired if we don't have an __parent__ # We can't be acquired if we don't have an __parent__
return 0 return 0
parent = aq_base(aq_parent(ob)) parent = aq_base(aq_parent(ob))
absId = absattr(ob.id) absId = absattr(ob.id)
if hasattr(parent, absId): if hasattr(parent, absId):
# Consider direct attributes not acquired # Consider direct attributes not acquired
skipping to change at line 127 skipping to change at line 106
m = sys.modules[__name__] m = sys.modules[__name__]
if hasattr(m, '__path__'): if hasattr(m, '__path__'):
r = m.__path__[0] r = m.__path__[0]
elif "." in __name__: elif "." in __name__:
r = sys.modules[__name__[:__name__.rfind('.')]].__path__[0] r = sys.modules[__name__[:__name__.rfind('.')]].__path__[0]
else: else:
r = __name__ r = __name__
return os.path.abspath(r) return os.path.abspath(r)
def Dictionary(**kw): def Dictionary(**kw):
import warnings
warnings.warn(
"The function `Dictionary` is deprecated "
"and will be removed in Zope 6.",
DeprecationWarning)
return kw # Sorry Guido return kw # Sorry Guido
 End of changes. 6 change blocks. 
46 lines changed or deleted 30 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)