src/source/dev_guide/internals.rst
branchdoc-dc
changeset 140 df3106def670
parent 139 d632f8d6140b
child 141 9ab9f762abed
equal deleted inserted replaced
139:d632f8d6140b 140:df3106def670
   192 
   192 
   193 Utilities
   193 Utilities
   194 ^^^^^^^^^
   194 ^^^^^^^^^
   195 
   195 
   196 - oid
   196 - oid
   197 	*oid*(value)
   197 	*oid*\(value)
   198 
   198 
   199 Return the **oid** of the value
   199 Return the **oid** of the value
   200 
   200 
   201 ----
   201 ----
   202 
   202 
   228 	- pano
   228 	- pano
   229 	- portrait
   229 	- portrait
   230 	- square
   230 	- square
   231 
   231 
   232 [lg, md, sm, xs]*_width
   232 [lg, md, sm, xs]*_width
   233 	[1-12] boostrat column size
   233 	[1-12] bootstrap column size
   234 
   234 
   235 css_class
   235 css_class
   236 	add a css class to the container of this illustration (<picture>)
   236 	add a css class to the container of this illustration (<picture>)
   237 
   237 
   238 img_class
   238 img_class
   332 into generated HTML code.
   332 into generated HTML code.
   333 Resource is given as a string made of package name as value (in dotted form) followed by a colon and by the resource name.
   333 Resource is given as a string made of package name as value (in dotted form) followed by a colon and by the resource name.
   334 
   334 
   335 For example:
   335 For example:
   336 
   336 
   337 .. code-block::
   337 
       
   338 .. code-block:: genshi
   338 
   339 
   339 	<tal:var define="tales:need_resource('pyams_content.zmi:pyams_content')" />
   340 	<tal:var define="tales:need_resource('pyams_content.zmi:pyams_content')" />
   340 
   341 
   341 
   342 
   342 ----
   343 ----
   358 -----
   359 -----
   359 
   360 
   360 Search engines
   361 Search engines
   361 --------------
   362 --------------
   362 
   363 
       
   364 .. _utilities:
       
   365 
       
   366 PyAMS Utilities
       
   367 ---------------
       
   368 
       
   369 PyAMS_utils provides a small set of utilities. You can create some of them as global utilities registered in
       
   370 the global components registry; other ones can be created manually by a site administrator and
       
   371 are then registered automatically.
       
   372 
       
   373 
       
   374 Server timezone
       
   375 ^^^^^^^^^^^^^^^
       
   376 
       
   377 To manage timezones correctly, and display datetimes based on current server timezone, all datetimes should
       
   378 be defined and stored in UTC.
       
   379 
       
   380 PyAMS_utils provides a :py:class:`ServerTimezoneUtility <pyams_utils.timezone.utility.ServerTimezoneUtility>` which
       
   381 allows you to assign a default timezone to your server.
       
   382 
       
   383 To display a datetime with correct timezone, you can use the :py:func:`tztime <pyams_utils.timezone.tztime>` function,
       
   384 which assign server timezone to the given parameter:
       
   385 
       
   386 .. code-block:: python
       
   387 
       
   388 	from datetime import datetime
       
   389 	from pyams_utils.timezone import tztime
       
   390 
       
   391 	now = datetime.utcnow()
       
   392 	my_date = tztime(now)  # converts *now* to server timezone
       
   393 
       
   394 We could imagine that datetimes could be displayed with current user timezone. But it's quite impossible to know
       
   395 the user timazone from a server request. The only options are:
       
   396 
       
   397 - you ask an authenticated user to update a timezone setting in his profile
       
   398 
       
   399 - you can include Javascript libraries which will try to detect browser timezone from their computer configuration, and
       
   400   do an AJAX request to update data in their session.
       
   401 
       
   402 That should require an update of :py:func:`tzinfo` adapter to get timezone info from session, request or user profile.
       
   403 
       
   404