plone.app.event.base

class plone.app.event.base.AnnotationAdapter(context)[source]

Abstract Base Class for an annotation storage.

If the annotation wasn’t set, it won’t be created until the first attempt to set a property on this adapter. So, the context doesn’t get polluted with annotations by accident.

plone.app.event.base.DT(dt, exact=False)[source]

Return a Zope DateTime instance from a Python datetime instance.

Parameters:
  • dt – Python datetime, Python date, Zope DateTime instance or string.
  • exact (Boolean) – If True, the resolution goes down to microseconds. If False, the resolution are seconds. Defaul is False.
Returns:

Zope DateTime

Return type:

Zope DateTime

plone.app.event.base.construct_calendar(events, start=None, end=None)[source]

Return a dictionary with dates in a given timeframe as keys and the actual occurrences for that date for building calendars. Long lasting events will occur on every day until their end.

Parameters:
  • events (list) – List of IEvent and/or IOccurrence objects, to construct a calendar data structure from.
  • start (Python datetime or date) – An optional start range date.
  • end (Python datetime or date) – An optional start range date.
Returns:

Dictionary with isoformat date strings as keys and event occurrences as values.

Return type:

dict

plone.app.event.base.date_speller(context, dt)[source]

Return a dictionary with localized and readably formatted date parts.

plone.app.event.base.dates_for_display(occurrence)[source]

Return a dictionary containing pre-calculated information for building <start>-<end> date strings.

Keys are:
‘start_date’ - date string of the start date ‘start_time’ - time string of the start date ‘end_date’ - date string of the end date ‘end_time’ - time string of the end date ‘start_iso’ - start date in iso format ‘end_iso’ - end date in iso format ‘same_day’ - event ends on the same day ‘same_time’ - event ends at same time ‘whole_day’ - whole day events ‘open_end’ - events without end time

The behavior os ulocalized_time() with time_only is odd. Setting time_only=False should return the date part only and not the time

>>> from DateTime import DateTime
>>> start = DateTime(2010,3,16,14,40)
>>> from zope.componen.hooks import getSite
>>> site = getSite()
>>> ulocalized_time(start, False,  time_only=True, context=site)
u'14:40'
>>> ulocalized_time(start, False,  time_only=False, context=site)
u'14:40'
>>> ulocalized_time(start, False,  time_only=None, context=site)
u'16.03.2010'
plone.app.event.base.default_end(context=None)[source]

Return the default end as python datetime for prefilling forms.

Returns:Default end datetime.
Return type:Python datetime
plone.app.event.base.default_start(context=None)[source]

Return the default start as python datetime for prefilling forms.

Returns:Default start datetime.
Return type:Python datetime
plone.app.event.base.default_timezone(context=None, as_tzinfo=False)[source]

Return the timezone from the portal or user.

Parameters:
  • context (Content object) – Optional context. If not given, the current Site is used.
  • as_tzinfo (boolean) – Return the default timezone as tzinfo object.
Returns:

Timezone identifier or tzinfo object.

Return type:

string or tzinfo object

plone.app.event.base.dt_end_of_day(dt)[source]

Returns a Python datetime instance set to the end time of the given day (23:59:59).

Parameters:dt (Python datetime) – datetime to set to the end time of the day.
Returns:datetime set to the end time of the day (23:59:59).
Return type:Python datetime
plone.app.event.base.dt_start_of_day(dt)[source]

Returns a Python datetime instance set to the start time of the given day (00:00:00).

Parameters:dt (Python datetime) – datetime to set to the start time of the day.
Returns:datetime set to the start time of the day (00:00:00).
Return type:Python datetime
plone.app.event.base.find_context(context, viewname=None, iface=None, as_url=False, append_view=True)[source]

Find the next context with a given view name or interface, up in the content tree, starting from the given context. This might not be the IPloneSiteRoot, but another subsite.

Parameters:
  • context – The context to start the search from.
  • viewname – (optional) The name of a view which a context should have configured as defaultView.
  • iface – (optional) The interface, the context to search for should implement.
  • as_url – (optional) Return the URL of the context found.
  • append_view – (optional) In case of a given viewname and called with as_url, append the viewname to the url, if the context hasn’t configured it as defaultView. Otherwise ignore this parameter.
Returns:

A context with the given view name, inteface or ISite root.

plone.app.event.base.first_weekday()[source]

Returns the number of the first Weekday in a Week, as defined in the registry. 0 is Monday, 6 is Sunday, as expected by Python’s datetime.

PLEASE NOTE: strftime %w interprets 0 as Sunday unlike the calendar module!

Returns:Index of first weekday [0(Monday)..6(Sunday)]
Return type:integer
plone.app.event.base.get_events(context, start=None, end=None, limit=None, ret_mode=1, expand=False, sort='start', sort_reverse=False, **kw)[source]

Return all events as catalog brains, possibly within a given timeframe.

Parameters:
  • context (Content object) – [required] A context object.
  • start (Python datetime.) – Date, from which on events should be searched.
  • end (Python datetime) – Date, until which events should be searched.
  • limit (integer) – Number of items to be returned.
  • ret_mode (integer [1|2|3]) –

    Return type of search results. These options are available:

    • 1 (brains): Return results as catalog brains.
    • 2 (objects): Return results as IEvent and/or
      IOccurrence objects.
    • 3 (accessors): Return results as IEventAccessor
      wrapper objects.
  • expand (boolean) – Expand the results to all occurrences (within a timeframe, if given). With this option set to True, the resultset also includes the event’s recurrence occurrences and is sorted by the start date. Only available in ret_mode 2 (objects) and 3 (accessors).
  • sort (string) – Catalog index id to sort on. Not available with expand=True.
  • sort_reverse (boolean) – Change the order of the sorting.
Returns:

Portal events, matching the search criteria.

Return type:

catalog brains

plone.app.event.base.guess_date_from(datestr, context=None)[source]

Returns a timezone aware date object if an arbitrary ASCII string is formatted in an ISO date format, otherwise None is returned.

Used for traversing and Occurence ids.

Parameters:
  • datestr (string) – Date string in an ISO format.
  • context (Content object) – Context object (for retrieving the timezone).
Returns:

Localized date object.

Return type:

Python date

plone.app.event.base.localized_now(context=None)[source]

Return the current datetime localized to the default timezone.

Parameters:context (Content object) – Context object.
Returns:Localized current datetime.
Return type:Python datetime
plone.app.event.base.localized_today(context=None)[source]

Return the current date localized to the default timezone.

Parameters:context (Content object) – Context object.
Returns:Localized current date.
Return type:Python date
plone.app.event.base.start_end_from_mode(mode, dt=None, context=None)[source]

Return a start and end date from a given mode string, like “today”, “past” or “future”. This can be used in event retrieval functions.

Parameters:
  • mode (string) –
    One of the following modes:
    ‘all’ Show all events. ‘past’: Show only past events with descending sorting. ‘future’: Show only future events (default). ‘today’: Show todays events. ‘now’: Show todays upcoming events. ‘7days’: Show events until 7 days in future. ‘day’: Return all events on the given day (dt parameter
    required)

    ‘week’: Show a weeks events, optionally from a given date.

    These settings override the start and end parameters.
    Not implemented yet: ‘month’: Show this month’s events.
  • dt (Python datetime) – Optional datetime for day mode.
plone.app.event.base.ulocalized_time(time, *args, **kwargs)[source]

Corrects for DateTime bugs doing wrong thing with timezones

plone.app.event.base.wkday_to_mon0(day)[source]

Converts an integer weekday number to a representation where Monday is 0 and Sunday is 6 (the datetime default), from a representation where Sunday is 0, Monday is 1 and Saturday is 6 (the strftime behavior).

Parameters:day (integer) – The weekday number [0(Sunday)..6]
Returns:The weekday number [0(Monday)..6]
Return type:integer
plone.app.event.base.wkday_to_mon1(day)[source]

Converts an integer weekday number to a representation where Monday is 1, Saturday is 6 and Sunday is 0 (the strftime behavior), from a representation where Monday is 0 and Sunday is 6 (the datetime default).

Parameters:day (integer) – The weekday number [0(Monday)..6]
Returns:The weekday number [0(Sunday)..6]
Return type:integer

Previous topic

plone.app.event API

Next topic

plone.app.event.interfaces

This Page