本文整理汇总了Python中zope.deprecation.deprecated函数的典型用法代码示例。如果您正苦于以下问题:Python deprecated函数的具体用法?Python deprecated怎么用?Python deprecated使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了deprecated函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _getFieldContext
def _getFieldContext(self, uid):
if uid is not None:
rc = getToolByName(aq_inner(self.context), 'reference_catalog')
return rc.lookupObject(uid)
else:
deprecated(FieldsView, missing_uid_deprecation)
return aq_inner(self.context)
示例2: remember
def remember(request, userid=_marker, **kw):
"""
Returns a sequence of header tuples (e.g. ``[('Set-Cookie', 'foo=abc')]``)
on this request's response.
These headers are suitable for 'remembering' a set of credentials
implied by the data passed as ``userid`` and ``*kw`` using the
current :term:`authentication policy`. Common usage might look
like so within the body of a view function (``response`` is
assumed to be a :term:`WebOb` -style :term:`response` object
computed previously by the view code):
.. code-block:: python
from pyramid.security import remember
headers = remember(request, 'chrism', password='123', max_age='86400')
response = request.response
response.headerlist.extend(headers)
return response
If no :term:`authentication policy` is in use, this function will
always return an empty sequence. If used, the composition and
meaning of ``**kw`` must be agreed upon by the calling code and
the effective authentication policy.
.. deprecated:: 1.6
Renamed the ``principal`` argument to ``userid`` to clarify its
purpose.
"""
if userid is _marker:
principal = kw.pop('principal', _marker)
if principal is _marker:
raise TypeError(
'remember() missing 1 required positional argument: '
'\'userid\'')
else:
deprecated(
'principal',
'The "principal" argument was deprecated in Pyramid 1.6. '
'It will be removed in Pyramid 1.9. Use the "userid" '
'argument instead.')
userid = principal
policy = _get_authentication_policy(request)
if policy is None:
return []
return policy.remember(request, userid, **kw)
示例3: kssValidateField
def kssValidateField(self, fieldname, value, uid=None):
'''Validate a given field
'''
# validate the field, actually
if uid is not None:
rc = getToolByName(aq_inner(self.context), 'reference_catalog')
instance = rc.lookupObject(uid)
else:
deprecated(ValidationView, missing_uid_deprecation)
instance = aq_inner(self.context)
field = instance.getField(fieldname)
if field.type in SKIP_KSSVALIDATION_FIELDTYPES:
return self.render()
error = field.validate(value, instance, {})
# XXX
if isinstance(error, str):
error = error.decode('utf', 'replace')
# replace the error on the page
self.getCommandSet('atvalidation').issueFieldError(fieldname, error, warning_only=False)
return self.render()
示例4: _integrate_plugins
def _integrate_plugins():
"""Integrate plugins to the context"""
from airflow.plugins_manager import operators_modules
for operators_module in operators_modules:
sys.modules[operators_module.__name__] = operators_module
globals()[operators_module._name] = operators_module
##########################################################
# TODO FIXME Remove in Airflow 2.0
if not os.environ.get('AIRFLOW_USE_NEW_IMPORTS', False):
from zope.deprecation import deprecated
for _operator in operators_module._objects:
operator_name = _operator.__name__
globals()[operator_name] = _operator
deprecated(
operator_name,
"Importing plugin operator '{i}' directly from "
"'airflow.operators' has been deprecated. Please "
"import from 'airflow.operators.[plugin_module]' "
"instead. Support for direct imports will be dropped "
"entirely in Airflow 2.0.".format(i=operator_name))
示例5: deprecate
def deprecate():
"""provide bbb for deprecations
note: warnings are not printed unless it is enabled
"""
from dexterity.membrane import behavior
from dexterity.membrane.behavior import group
from dexterity.membrane.behavior import user
from dexterity.membrane.behavior import password
behavior.membranegroup = deprecated(
group,
'module membranegroup is now named group.'
)
behavior.membraneuser = deprecated(
user,
'module membraneuser is now named user.'
)
behavior.membranepassword = deprecated(
password,
'module membranepassword is now named password.'
)
示例6: kssValidateMultilanguageField
def kssValidateMultilanguageField(self, fieldname, uid=None):
'''Validate a given multilanguage field
'''
# validate the field, actually
if uid is not None:
rc = getToolByName(aq_inner(self.context), 'reference_catalog')
instance = rc.lookupObject(uid)
else:
deprecated(ValidationView, missing_uid_deprecation)
instance = aq_inner(self.context)
field = instance.getField(fieldname)
if field.type in SKIP_KSSVALIDATION_FIELDTYPES or \
not IMultilanguageField.providedBy(field):
return self.render()
value = dict([(key[key.find('___')+3:-3], value) for key, value in self.request.form.items() if key.startswith(fieldname)])
error = field.validate(value, instance, {}, REQUEST=self.request)
# XXX
if isinstance(error, str):
error = error.decode('utf', 'replace')
# replace the error on the page
self.getCommandSet('atvalidation').issueFieldError(fieldname, error)
return self.render()
示例7: caller_package
:term:`Chameleon` ZPT template using the template implied by the
``path`` argument. The ``path`` argument may be a
package-relative path, an absolute path, or a :term:`asset
specification`.
.. warning::
This API is deprecated in :app:`Pyramid` 1.0. Use
:func:`pyramid.renderers.get_renderer` instead.
"""
package = caller_package()
factory = renderers.RendererHelper(name=path, package=package)
return factory.get_renderer()
deprecated(
'get_renderer',
'(pyramid.chameleon_zpt.get_renderer is deprecated '
'as of Pyramid 1.0; instead use pyramid.renderers.get_renderer)')
def get_template(path):
""" Return the underyling object representing a :term:`Chameleon`
ZPT template using the template implied by the ``path`` argument.
The ``path`` argument may be a package-relative path, an absolute
path, or a :term:`asset specification`.
.. warning::
This API is deprecated in :app:`Pyramid` 1.0. Use
the ``implementation()`` method of a template renderer retrieved via
:func:`pyramid.renderers.get_renderer` instead.
"""
package = caller_package()
示例8: static
class static(static_view):
""" Backwards compatibility alias for
:class:`pyramid.static.static_view`; it overrides that class' constructor
to pass ``use_subpath=True`` by default. This class is deprecated as of
:app:`Pyramid` 1.1. Use :class:`pyramid.static.static_view` instead
(probably with a ``use_subpath=True`` argument).
"""
def __init__(self, root_dir, cache_max_age=3600, package_name=None):
if package_name is None:
package_name = caller_package().__name__
static_view.__init__(self, root_dir, cache_max_age=cache_max_age,
package_name=package_name, use_subpath=True)
deprecated(
'static',
'The "pyramid.view.static" class is deprecated as of Pyramid 1.1; '
'use the "pyramid.static.static_view" class instead with the '
'"use_subpath" argument set to True.')
def render_view_to_response(context, request, name='', secure=True):
""" Call the :term:`view callable` configured with a :term:`view
configuration` that matches the :term:`view name` ``name``
registered against the specified ``context`` and ``request`` and
return a :term:`response` object. This function will return
``None`` if a corresponding :term:`view callable` cannot be found
(when no :term:`view configuration` matches the combination of
``name`` / ``context`` / and ``request``).
If `secure`` is ``True``, and the :term:`view callable` found is
protected by a permission, the permission will be checked before calling
the view function. If the permission check disallows view execution
示例9: ProposalSchema
class ProposalSchema(colander.MappingSchema):
"""Data structure for organizational information."""
# TODO: check exact length restrictions
budget = CurrencyAmount(missing=colander.required,
validator=colander.Range(min=0, max=50000))
creator_participate = Boolean()
location_text = SingleLine(validator=colander.Length(max=100))
address = Text()
proposal_meta = sheet_meta._replace(isheet=IProposal,
schema_class=ProposalSchema)
class IWorkflowAssignment(workflow.IWorkflowAssignment):
"""Marker interface for the kiezkassen workflow assignment sheet."""
deprecated('IWorkflowAssignment',
'Backward compatible code use IWorkflowAssignment instead')
def includeme(config):
"""Register sheets."""
add_sheet_to_registry(proposal_meta, config.registry)
示例10: getattr
if title:
return title
item_id = getattr(obj, 'getId', None)
if safe_callable(item_id):
item_id = item_id()
if item_id and not isIDAutoGenerated(context, item_id):
return item_id
if empty_value is _marker:
empty_value = getEmptyTitle(context)
return empty_value
def getSiteEncoding(context):
return 'utf-8'
deprecated('getSiteEncoding',
('`getSiteEncoding` is deprecated. Plone only supports UTF-8 '
'currently. This method always returns "utf-8"'))
# XXX portal_utf8 and utf8_portal probably can go away
def portal_utf8(context, str, errors='strict'):
# Test
unicode(str, 'utf-8', errors)
return str
# XXX this is the same method as above
def utf8_portal(context, str, errors='strict'):
# Test
unicode(str, 'utf-8', errors)
return str
示例11: BaseCookieSessionFactory
)
return BaseCookieSessionFactory(
signed_serializer,
cookie_name=cookie_name,
max_age=max_age,
path=path,
domain=domain,
secure=secure,
httponly=httponly,
samesite=samesite,
timeout=timeout,
reissue_time=reissue_time,
set_on_exception=set_on_exception,
)
check_csrf_origin = check_csrf_origin # api
deprecated(
'check_csrf_origin',
'pyramid.session.check_csrf_origin is deprecated as of Pyramid '
'1.9. Use pyramid.csrf.check_csrf_origin instead.',
)
check_csrf_token = check_csrf_token # api
deprecated(
'check_csrf_token',
'pyramid.session.check_csrf_token is deprecated as of Pyramid '
'1.9. Use pyramid.csrf.check_csrf_token instead.',
)
示例12: deprecated
"""
A function that calls :meth:`pyramid.request.Request.has_permission`
and returns its result.
.. deprecated:: 1.5
Use :meth:`pyramid.request.Request.has_permission` instead.
.. versionchanged:: 1.5a3
If context is None, then attempt to use the context attribute of self;
if not set, then the AttributeError is propagated.
"""
return request.has_permission(permission, context)
deprecated(
'has_permission',
'As of Pyramid 1.5 the "pyramid.security.has_permission" API is now '
'deprecated. It will be removed in Pyramd 1.8. Use the '
'"has_permission" method of the Pyramid request instead.'
)
def authenticated_userid(request):
"""
A function that returns the value of the property
:attr:`pyramid.request.Request.authenticated_userid`.
.. deprecated:: 1.5
Use :attr:`pyramid.request.Request.authenticated_userid` instead.
"""
return request.authenticated_userid
deprecated(
示例13: object
from zope.interface import implementer
_marker = object()
@implementer(INameChooser)
@adapter(ILanguageRootFolder)
class LRFNameChooser(NormalizingNameChooser):
"""Special name chooser to fix issue where createContentInContainer is
used to create a new content into LRF with an id, which exists already
in the parent folder.
"""
def chooseName(self, name, object):
chosen = super(LRFNameChooser, self).chooseName(name, object)
if chosen in self.context.objectIds():
old_id = getattr(object, 'id', None)
object.id = chosen
chooser = ITranslationIdChooser(object)
chosen = chooser(self.context, self.context.getId())
object.id = old_id
return chosen
@implementer(ILanguageRootFolder, INavigationRoot)
class LanguageRootFolder(Container):
"""Deprecated LanguageRootFolder custom base class"""
deprecated('LanguageRootFolder',
'LanguageRootFolders should be migrate to DexterityContainers')
示例14: add_renderer_globals
context, request, **kwargs)
def add_renderer_globals(event):
if event.get('renderer_name') != 'json':
request = event['request']
api = getattr(request, 'template_api', None)
if api is None and request is not None:
api = template_api(event['context'], event['request'])
event['api'] = api
def is_root(context, request):
return context is request.root
deprecated('is_root', "'is_root' is deprecated as of Kotti 1.0.0. "
"Use the 'root_only=True' if you were using this as a "
"'custom_predicates' predicate.")
class Slots(object):
def __init__(self, context, request):
self.context = context
self.request = request
def __getattr__(self, name):
for event_type in slot_events:
if event_type.name == name:
break
else:
raise AttributeError(name)
value = []
示例15: isinstance
if isinstance(anchor, unicode):
anchor = anchor.encode('utf-8')
anchor = '#' + anchor
if elements:
suffix = _join_elements(elements)
else:
suffix = ''
return resource_url + suffix + qs + anchor
model_url = resource_url # b/w compat (forever)
deprecated(
'model_url',
'pyramid.url.model_url is deprecated as of Pyramid 1.0. Use'
'``pyramid.url.resource_url`` instead (API-compat, simple '
'rename).')
def static_url(path, request, **kw):
"""
Generates a fully qualified URL for a static :term:`asset`.
The asset must live within a location defined via the
:meth:`pyramid.config.Configurator.add_static_view`
:term:`configuration declaration` (see :ref:`static_assets_section`).
.. note:: Calling :meth:`pyramid.Request.static_url` can be used to
achieve the same result as :func:`pyramid.url.static_url`.
Example::