+ +
+

Custom PyAMS utilities

+

PyAMS_utils provides a small set of utilities. You can create some of them as global utilities registered in +the global components registry; other ones can be created manually by a site administrator and +are then registered automatically.

+
+

Server timezone

+

To manage timezones correctly, and display datetimes based on current server timezone, all datetimes should +be defined and stored in UTC.

+

PyAMS_utils provides a ServerTimezoneUtility which +allows you to assign a default timezone to your server.

+

To display a datetime with correct timezone, you can use the tztime function, +which assign server timezone to the given parameter:

+
from datetime import datetime
+from pyams_utils.timezone import tztime
+
+now = datetime.utcnow()
+my_date = tztime(now)  # converts *now* to server timezone
+
+
+

We could imagine that datetimes could be displayed with current user timezone. But it’s quite impossible to know +the user timazone from a server request. The only options are:

+
    +
  • you ask an authenticated user to update a timezone setting in his profile
  • +
  • you can include Javascript libraries which will try to detect browser timezone from their computer configuration, and +do an AJAX request to update data in their session.
  • +
+

That should require an update of tzinfo() adapter to get timezone info from session, request or user profile.

+
+
+

ZEO connection

+

Several PyAMS utilities (like the tasks scheduler or the medias converter) are working with dedicated processes, +are connected to main PyAMS process through ØMQ, and use ZEO connections for their PyAMS database access.

+

Clients of these processes have to send settings of the ZEO connections that they should use.

+

The ZEOConnection utility can be created by the site manager through the web management interface (ZMI) from the +Control panel:

+_images/zeo-add-menu.png +

ZEO connection creation form allows you to define all settings of a ZEO connection:

+_images/zeo-add-form.png +
+
+ + +