Skip to main content

Adaptable string interpolation

Project description

Provides ${id} style string interpolation using named adapters to look up variables. This is meant to provide a trivially simple template system for clients like plone.app.contentrules.

To interpolate a string in context, just follow the pattern:

from plone.stringinterp.interfaces import IStringInterpolator

IStringInterpolator(context)("Here is the title: ${title}")

Substitution of variables that are part of the Dublin Core are provided with the package. To provide additional substitutions, provide a named adapter implementing interfaces.IStringSubstitution for your context. The adapter name is used for the lookup.

You can also wrap your context with IContextWrapper adapter if you need to pass custom messages within your substitutions.

Implemented Substitutions

All Content

  • id

  • parent_id

  • url

  • parent_url

Minimal Dublin Core

  • title

  • description

  • type (content type)

Workflow Aware

  • review_state

  • review_state_title

Dublin Core

  • creator

  • creator_fullname

  • creator_email

  • creators

  • creators_emails

  • contributors

  • contributors_emails

  • subject

  • format (mime type)

  • language

  • rights

  • identifier

Catalogable Dublin Core

Everything should be in long local time format

  • created

  • effective

  • expires

  • modified

Member / Group Information for roles on content

  • owner_emails

  • reviewer_emails

  • manager_emails

  • member_emails

  • user_email

Current User Information

  • user_fullname

  • user_id

Last Change (workflow or version) Information

  • change_comment

  • change_title

  • change_type

  • change_authorid

Source Code

Contributors please read the document Process for Plone core’s development

Sources and issue tracker are at the Plone code repository hosted at Github.

Changelog

3.0.0 (2026-05-18)

Internal:

  • Make final release, no further changes.

3.0.0a2 (2026-03-27)

Bug fixes:

  • Catch exceptions from string substitution adapters instead of crashing. Fixes content rule email actions failing when a substitution variable raises an error. @jensens (#1358)

Internal:

  • Update configuration files. [plone devs]

3.0.0a1 (2025-11-19)

Breaking changes:

  • Replace pkg_resources namespace with PEP 420 native namespace. Support only Plone 6.2 and Python 3.10+. (#3928)

2.0.3 (2025-09-10)

Internal:

  • Move distribution to src layout [gforcada] (#4217)

2.0.2 (2024-01-22)

Internal:

  • Update configuration files. [plone devs] (6e36bcc4, 7723aeaf)

2.0.1 (2023-04-14)

Internal:

  • Update configuration files. [plone devs] (93e1ab65)

2.0.0 (2023-03-21)

Breaking changes:

  • pyupgrade, drop support for Python < 3.8. isort, black, manual edits. Fix deprecation warnings for imports from Products.CMFPlone. Import and depend from plone.base. (#15)

1.3.3 (2020-09-07)

Bug fixes:

  • Resolve deprecation warning [gforcada] (#14)

1.3.2 (2020-04-22)

Bug fixes:

  • Minor packaging updates. (#1)

1.3.1 (2018-11-04)

Bug fixes:

  • The Format accessor should actually return the format attribute (see plone/Products.CMFPlone#2540) [ale-rt]

1.3.0 (2018-09-28)

New features:

  • Add support for Python 3. [pbauer]

1.2.1 (2016-11-18)

New features:

  • Removed ZopeTestCase. [maurits]

1.2 (2016-09-20)

New features:

  • Provide a ContextWrapper adapter in order to easily pass custom messages to StringInterpoator [avoinea]

1.1.4 (2016-08-18)

Bug fixes:

  • Use zope.interface decorator. [gforcada]

1.1.3 (2016-05-25)

Fixes:

  • Adapt to changes in SimpleViewClass in zope4. [pbauer]

  • Fix typo [staeff]

1.1.2 (2015-03-13)

Fixes:

  • Fixed “RuntimeError: maximum recursion depth exceeded” in recursiveGetGroupUsers when you have a group A containing group B containing group A. [vincentfretin]

1.1.1 (2014-11-01)

  • Add creator, creator_fullname, creator_email, creators_emails and contributors_emails [avoinea]

1.1 (2014-02-25)

  • Add portal_url and portal_title. [thomasdesvenain]

  • Add parent_id. [maartenkling]

  • Convert tests to plone.app.testing for Plone 5. [davisagli]

1.0.10 (2013-05-30)

  • Added review_state_title substitution variable. [ichim-david]

1.0.9 (2013-05-26)

  • Added id substitution variable that works with content events and user events. [thomasdesvenain]

  • Email substitutions are not restricted to contentish anymore, so we can use them with user events. [thomasdesvenain]

1.0.8 (2013-05-23)

  • Added editor_emails substitution variable. [thomasdesvenain]

1.0.7 (2012-08-11)

  • Added parent_title substitution, which gets the title of the container. [thomasdesvenain]

  • Fixed user_fullname substitution : display user id if fullname is not set. [thomasdesvenain]

  • Do not restrict string interpolation to IContentish if not necessary. Fixes email content rule related with plone.app.discussion comments. Refs https://dev.plone.org/ticket/13047 [thomasdesvenain]

1.0.6 (2012-08-04)

  • Added parent_url substitution (the url of the object parent). [thomasdesvenain]

1.0.5 (2012-01-26)

  • Recursive get members works in a non wrapped context (when getting PloneGroups instead of GroupData from GroupTool) [thomasdesvenain]

  • Add MANIFEST.in [WouterVH]

1.0.4 - 2011-04-01

  • Added contributor_emails and reader_emails substitution variables. [thomasdesvenain]

1.0.3 - 2010-11-11

  • Fix a bug with member email substitutions when a user has been removed from acl_users. [rossp]

1.0.2 - 2010-09-20

  • Role email substitution works with user that have role through a group. [thomasdesvenain]

1.0.1 - 2010-09-15

  • Internationalized ${type} substitution. [thomasdesvenain]

  • Fixed: get emails for role works with local roles. [thomasdesvenain]

1.0 - 2010-07-18

  • Update license to GPL version 2 only. [hannosch]

1.0b1 - 2009-11-12

  • Initial release.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

plone_stringinterp-3.0.0.tar.gz (26.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

plone_stringinterp-3.0.0-py3-none-any.whl (23.9 kB view details)

Uploaded Python 3

File details

Details for the file plone_stringinterp-3.0.0.tar.gz.

File metadata

  • Download URL: plone_stringinterp-3.0.0.tar.gz
  • Upload date:
  • Size: 26.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for plone_stringinterp-3.0.0.tar.gz
Algorithm Hash digest
SHA256 f432bc7ca70192c2bca1dc7b1e49e8393ef4d1596d55c20b45c2e604bfcda361
MD5 0221bd9f5d4f6310fbae10e27d7aa432
BLAKE2b-256 c14cb7785fc39c94461ba474582cc027f9b4d28dd9c5fbc9106b8cc6aa8456c4

See more details on using hashes here.

File details

Details for the file plone_stringinterp-3.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for plone_stringinterp-3.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 003b9f33ffe32815c0c1d18b44f2e567b801872ef0a60a67c625652bd99b522d
MD5 205d2a85d4f9a474716f18f0e750a9bd
BLAKE2b-256 71d5a5ad0a289d0a388dfdfba00cbc90af930627be233e954fa534a783299df0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page