Skip to main content

A country widget for Archetypes

Adds a new tool, portal_countryutil to the Plone root, which lets you manage a list of areas which may contain several countries from the official ISO-country list via the ZMI. A complete list of areas and their countries is being created at install time.

Provides three widgets which you can use in your own Archetype:

CountryWidget

the areas and countries defined in the country tool are then rendered as a dropdown (with <optgroup>).

AreaWidget

provides a dropdown with all areas you have defined.

MultiCountryWidget

for use with LinesField, lets you select multiple countries

Examples

Here is some code that demonstrates how to use those widgets:

---- YourArcheType.py ----

# Import the widget/s:
from Products.ATCountryWidget.Widget import CountryWidget, AreaWidget

# Define the field/s in your schema:
[...]

 StringField(
    'country',
    validators=('isValidISOCountry',),
    widget=CountryWidget(label='Country',
                         provideNullValue=1,   # this is default
                         nullValueTitle='-',   # this is default
                         omitCountries=None,   # this is default, can be a
                                               # list of country codes which
                                               # are not displayed
                         description='Select a country')
 ),

[... and/or ...]

 StringField(
    'area',
    widget=AreaWidget(label='Area',
                      provideNullValue=1,      # this is default
                      nullValueTitle='-',      # this is default
                      description='Select an area')
 ),

[... and/or ...]

 LinesField(
    'countries',
    widget=MultiCountryWidget(label='Countries',
                         omitCountries=None,   # this is default, can be a
                                               # list of country codes which
                                               # are not displayed
                         description='Select countries')
 ),

[...]

Use without Archetypes

To use your countrylist in a custom page template outside of an Archetype (e.g. in a search form) you can directly use the API the country tool provides:

<select tal:define="countrytool here/portal_countryutils">
  <option>Choose...</option>
  <optgroup
      label="Western Europe"
      tal:repeat="area countrytool/listAreas"
      tal:attributes="label area/name">
    <option
      value="DE"
      tal:repeat="country area/countries"
      tal:content="country/name"
      tal:attributes="value country/isocc">Germany
    </option>
  </optgroup>
</select>

For more details on how to customize content-types, add custom fields to content-types, see Martin’s tutorial: http://plone.org/documentation/kb/richdocument/extending-atct

Changelog

2011-04-11
  • Release Plone 4 compat version

2009-02-21
  • Released as egg.

2006-04-19
  • Added patch from Norman H. Voss (missing country/rearranged default areas)

  • Updated README to cover MultiCountryWidget

2006-03-14
  • Added multiselect widget (MultiCountryWidget)

2005-09-02
  • Compatibility with Plone 2.1 (RC3)

2005-06-29
  • Added parameter ‘omitCountries’ to CountryWidget. Country ISO codes in this list are omitted from display in selection.

2005-02-20
  • added listing of languages and their two letter ISO codes

2004-08-30
  • release 0.2

  • added area-widget

  • provideNullValue & nullValue properties for widgets

  • creation of complete area-country structure in installer

  • migrated to AT 1.3 beta

2004-07-05
  • release 0.1.1

  • added validator

2004-06-29
  • initial release 0.1

Authors

Christian Zagrodnick (cz@gocept.com) Michael Howitz (mh@gocept.com) Daniel Havlik (dh@gocept.com)

Additional credits:

  • Norman H. Voss for a patch (04/2006)

  • Alex Clark for releasing Plone 4 compat version (from gocept trunk moved to the collective, 04/2011)

Metadata

Release files for Products.ATCountryWidget 0.2.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for Products.ATCountryWidget 0.2.6
File Size Uploaded Provenance
Products.ATCountryWidget-0.2.6.zip 46.6 kB Without provenance Details

Release files / Products.ATCountryWidget-0.2.6.zip

Download URL Products.ATCountryWidget-0.2.6.zip
Size 46.6 kB
Tags Source
SHA-256 checksum
How to use checksums
329600d2778bd3000548710ae5298790850a55aedf1b024021fb5d1287b8b1ac
BLAKE2b-256 checksum
How to use checksums
f3b33860289dfd1a5c0d6f864a1f2d90b9651cff9e4c3423d4b4b52dd99afa54
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for Products.ATCountryWidget 0.2.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.2.6 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page