Use plone.app.event.base.DT to convert datetime -> DateTime
This commit is contained in:
		
							parent
							
								
									a069f49719
								
							
						
					
					
						commit
						ab92def1a6
					
				@ -6,6 +6,7 @@ Also provide event handlers to actually catalog the comments.
 | 
				
			|||||||
from DateTime import DateTime
 | 
					from DateTime import DateTime
 | 
				
			||||||
from plone.app.discussion.interfaces import IComment
 | 
					from plone.app.discussion.interfaces import IComment
 | 
				
			||||||
from plone.app.discussion.interfaces import IConversation
 | 
					from plone.app.discussion.interfaces import IConversation
 | 
				
			||||||
 | 
					from plone.app.event.base import DT
 | 
				
			||||||
from plone.base.utils import safe_text
 | 
					from plone.base.utils import safe_text
 | 
				
			||||||
from plone.indexer import indexer
 | 
					from plone.indexer import indexer
 | 
				
			||||||
from plone.uuid.interfaces import IUUID
 | 
					from plone.uuid.interfaces import IUUID
 | 
				
			||||||
@ -102,43 +103,19 @@ def in_response_to(object):
 | 
				
			|||||||
@indexer(IComment)
 | 
					@indexer(IComment)
 | 
				
			||||||
def effective(object):
 | 
					def effective(object):
 | 
				
			||||||
    # the catalog index needs Zope DateTime instead of Python datetime
 | 
					    # the catalog index needs Zope DateTime instead of Python datetime
 | 
				
			||||||
    return DateTime(
 | 
					    return DT( object.creation_date )
 | 
				
			||||||
        object.creation_date.year,
 | 
					 | 
				
			||||||
        object.creation_date.month,
 | 
					 | 
				
			||||||
        object.creation_date.day,
 | 
					 | 
				
			||||||
        object.creation_date.hour,
 | 
					 | 
				
			||||||
        object.creation_date.minute,
 | 
					 | 
				
			||||||
        object.creation_date.second,
 | 
					 | 
				
			||||||
        object.creation_date.tzname(),
 | 
					 | 
				
			||||||
    )
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@indexer(IComment)
 | 
					@indexer(IComment)
 | 
				
			||||||
def created(object):
 | 
					def created(object):
 | 
				
			||||||
    # the catalog index needs Zope DateTime instead of Python datetime
 | 
					    # the catalog index needs Zope DateTime instead of Python datetime
 | 
				
			||||||
    return DateTime(
 | 
					    return DT(object.modification_date)
 | 
				
			||||||
        object.creation_date.year,
 | 
					 | 
				
			||||||
        object.creation_date.month,
 | 
					 | 
				
			||||||
        object.creation_date.day,
 | 
					 | 
				
			||||||
        object.creation_date.hour,
 | 
					 | 
				
			||||||
        object.creation_date.minute,
 | 
					 | 
				
			||||||
        object.creation_date.second,
 | 
					 | 
				
			||||||
        object.creation_date.tzname(),
 | 
					 | 
				
			||||||
    )
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@indexer(IComment)
 | 
					@indexer(IComment)
 | 
				
			||||||
def modified(object):
 | 
					def modified(object):
 | 
				
			||||||
    # the catalog index needs Zope DateTime instead of Python datetime
 | 
					    # the catalog index needs Zope DateTime instead of Python datetime
 | 
				
			||||||
    return DateTime(
 | 
					    return DT(object.modification_date)
 | 
				
			||||||
        object.modification_date.year,
 | 
					 | 
				
			||||||
        object.modification_date.month,
 | 
					 | 
				
			||||||
        object.modification_date.day,
 | 
					 | 
				
			||||||
        object.modification_date.hour,
 | 
					 | 
				
			||||||
        object.modification_date.minute,
 | 
					 | 
				
			||||||
        object.modification_date.second,
 | 
					 | 
				
			||||||
        object.modification_date.tzname(),
 | 
					 | 
				
			||||||
    )
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Override the conversation indexers for comments
 | 
					# Override the conversation indexers for comments
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user