tags:

views:

115

answers:

3

In this link, http://plone.org/documentation/how-to/set-default-datetimefield-current-date-time it describes how to do this with new Schema attributes. I could update all umpteen content types in our system use this method, but I would prefer something a bit less work intensive, since if I have to change umpteen content types it will be all too easy to make a mistake.

A: 

I could just make 'published' be the default work flow state. That should address the issue.

pydanny
Unfortunately, this solution is not acceptable. My task is to make the default publication date on new content items to be the current date. Not create a work flow change.
pydanny
+1  A: 

maybe a js soln? have an onload event that looks for datetime widgets by id (or one of those common attributes) and then reset the time based on the browser time. You can filter new vs edit based on whether or not a non-prefilled required attribute has been filled yet (i.e. Title)

So you mean use a bit of JavaScript do default empty effectiveDate fields to the current date? I'll give that a try.
pydanny
This method worked perfectly! Entirely view based so I did not have to modify umpteen content types!
pydanny
+1  A: 

You could use archetypes.schemaextender to modify those types with an adapter:

in your configure.zcml

<adapter
    factory=".adapters.DefaultDateModifier"
    name="my-package-defaultdate"
    />

in the adapters.py

class DefaultDateModifier(object):
    """DefaultDateModifier adapter
    """
    # XXX optionally adapt your content items iface here
    adapts(ATCTMixin)
    implements(ISchemaModifier)

    def fiddle(self, schema):
        # TODO switch out the default_method here...
        pass

    def __init__(self, context):
        self.context = context
claytron
How would that work against many (50+) Plone 2.5 content types running in Plone 3.x? Would I have to modify all of the many content types? Because that is what I would prefer not to do.
pydanny
If all the types had a common interface or subclass (ATCTMixin for example) then you would just need to extend that once. Then all the types get the addition for free.You can also tag all those types with an interface via zcml if it came down to it. Then extend via that interface.
claytron
This would be a great fix *but* we don't have a common interface or subclass.
pydanny