How to add own syntax classes for extended attributes

Your own syntax classes can be created in


and linked to


As an example, a regular expression class could look like this
# coding=utf-8
import re

class device_description(simple):
    regex = re.compile('(?u)(^[a-zA-Z0-9])[a-zA-Z0-9._ -]*([a-zA-Z0-9]$)')
    error_message = _("Value must not contain anything other than digits, letters, dots or spaces, must be at least 2 characters long, and start and end with a digit or letter!")

This syntax class can be used in your extended attribute to check the inputs for your own device description. The name is “device_description” just like the syntax class name.
If you have a multi server environment, you should copy the syntax class on all your servers., because it is not automatically replicated.