Skip to content

collective/collective.address

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

71 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

collective.address

This package provides some Dexterity behavior to be used in Dexterity based types for:

IAddress behavior, some fields to describe the Address data.

The IAddress Behavior

The IAddress Behavior.

Using the IAddress Behavior into a custom content type.

Using the IAddress Behavior into a custom content type.


IContact behavior, some fields to describe the Contact data.

The IContact Behavior

The IContact Behavior.

Using the IContact Behavior into a custom content type

Using the IContact Behavior into a custom content type.


IPerson behavior, some fields to describe the Person data.

The IPerson Behavior

The IPerson Behavior.

Using the IPerson Behavior into a custom content type

Using the IPerson Behavior into a custom content type.


ISocial behavior, some fields to describe the Person data.

The ISocial Behavior

The ISocial Behavior.

Using the ISocial Behavior into a custom content type.

Using the ISocial Behavior into a custom content type.


Examples

This add-on can be seen in action at the following add-ons:

Translations

This product has been translated into

  • Deutsch
  • Francese
  • Italian
  • Spanish

Installation

If you installed Plone with Cookieplone, you can install collective.address add-on from a source control system such as GitHub.

Add a line with collective.address in the backend/requirements.txt file.

collective.address

Next add the add-on to zcml_package_includes in the file backend/instance.yaml so that its configuration will load.

default_context:
    zcml_package_includes: project_title, collective.address

Finally, add the package's source to the mx.ini file.

[collective.address]
url = https://github.com/collective/collective.address.git
pushurl = git@github.com:collective/collective.address.git
branch = master

To actually download and install the new add-on, run the following command.

make backend-build

Now restart the backend.


If you installed Plone with buildout, you can install collective.address add-on by adding it to your buildout eggs list like so:

[buildout]

...

eggs =
    collective.address

and then running bin/buildout

Now restart the instance.

Tips

The following are some tips on how to use this add-on.

How to provide a default value for the country field

If you want to provide a default value for the IAddress country field, you can provide an ComputedWidgetAttribute adapter like so:

from zope.component import provideAdapter
from z3c.form.widget import ComputedWidgetAttribute
from collective.address.behaviors import IAddress

DEFAULT_COUNTRY = "040"  # Austria
provideAdapter(ComputedWidgetAttribute(
    lambda data: DEFAULT_COUNTRY,
    field=IAddress['country']), name='default')

The country code must be the numeric ISO 3166-1 code as a string. You can find the list of codes here: https://en.wikipedia.org/wiki/ISO_3166-1_numeric

If you want to play with the country codes in a Python shell, you can use the pycountry package like so:

>>> import pycountry
>>> austria = pycountry.countries.get(numeric='040')
>>> austria
Country(alpha_2='AT', alpha_3='AUT', flag='🇦🇹', name='Austria', numeric='040', official_name='Republic of Austria')
>>> spain = pycountry.countries.get(alpha_2='ES')
>>> spain
Country(alpha_2='ES', alpha_3='ESP', flag='🇪🇸', name='Spain', numeric='724', official_name='Kingdom of Spain')

You can install pycountry via pip:

pip3 install pycountry

For more information, see the pycountry documentation.

Compatibility

  • Tested with Python 3.12 and Plone 6.1.2.

License

The project is licensed under the GPLv2.

Contribute

Author

About

Dexterity address behavior.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors