hvelarde
(hvelarde)
March 7, 2016, 11:42pm
1
in Plone 5 we removed portal_calendar .
we were using that tool to list a content type as Event-like: if a content type was listed in calendar_types
, it was an Event; see for instance, this code:
else:
return brain.start
def get_localized_time(self, datetime, format):
"""Return datetime localized as selected in layout configurations.
:param datetime: [required] datetime to be formatted
:type datetime: DateTime, datetime or date
:param format: [required] format to be used
:type format: string
:returns: localized time
:rtype: unicode
"""
options = {
'datetime': dict( # u'Jul 15, 2015 01:23 PM'
datetime=datetime, long_format=True, time_only=False),
'dateonly': dict( # u'Jul 15, 2015
datetime=datetime, long_format=False, time_only=False),
'timeonly': dict( # u'01:23 PM'
datetime=datetime, long_format=False, time_only=True),
This file has been truncated. show original
what would be the canonical way then? remember we have a problem with field naming in plone.app.event .
1 Like
hvelarde
(hvelarde)
March 8, 2016, 12:19am
2
I ended up with this:
collective:master
← collective:hvelarde-calendar-tool
opened 12:15AM - 08 Mar 16 UTC
comments are welcome, any way.
1 Like
thet
(Johannes Raggam)
March 8, 2016, 1:47am
3
Here is an example how plone.app.event searches for event like objects:
:type sort: string
:param sort_reverse: Change the order of the sorting.
:type sort_reverse: boolean
:returns: Portal events, matching the search criteria.
:rtype: catalog brains, event objects or IEventAccessor object wrapper,
depending on ret_mode.
"""
start, end = _prepare_range(context, start, end)
query = {}
query['object_provides'] = IEvent.__identifier__
query.update(start_end_query(start, end))
if 'path' not in kw:
# limit to the current navigation root, usually (not always) site
portal = getSite()
navroot = getNavigationRootObject(context, portal)
query['path'] = '/'.join(navroot.getPhysicalPath())
Any object, which provides plone.event.interfaces.IEvent
is an event-like objet.
For Dexterity, there is the plone.app.event.dx.interfaces.IDXEvent
, which is used by plone.app.event to mark Dexterity events as such.
The plone.app.event.dx.behaviors.IEventBasic
derives from that. Thus, any Dexterity object which uses the IEventBasic behavior is an event-like object. Adding this behavior to your content types is the easiest way to make an object eventish.
1 Like
hvelarde
(hvelarde)
March 8, 2016, 1:55am
4
that interface is just a marker with no methods/attributes described on it:
shouldn't be good to provide a description of what an Event should be?
jensens
(Jens W. Klein)
March 8, 2016, 8:53am
5
IMO it is defined at minimum by start and end date.
1 Like
thet
(Johannes Raggam)
March 8, 2016, 9:27am
6
yes, start and end date should be the necessary minimum. That should probably be added to the Interface.
1 Like