"""
$Id: __init__.py 1074 2005-04-05 02:38:02Z sidnei $
"""
from zope.interface import Interface
from zope.configuration.fields import GlobalObject, Path
from zope.schema import TextLine
from zope.app.security.fields import Permission
from zope.app.form.browser.metadirectives import ICommonInformation as IBase

class ICommonInformation(IBase):
    """
    Common information for all successive directives
    """

    schema = GlobalObject(
        title=u"Schema",
        description=u"The schema from which the form is generated.",
        required=False
        )

    permission = Permission(
        title=u"Permission",
        description=u"The permission needed to use the view.",
        required=False
        )

class IAddForm(ICommonInformation):

    product = TextLine(
        title=u"Product Name",
        description=u"The product name where the archetype can be found.",
        required=True
        )

    meta_type = TextLine(
        title=u"Meta Type",
        description=u"The meta_type for the target archetype.",
        required=True
        )

    portal_type = TextLine(
        title=u"Portal Type",
        description=u"""
        The portal_type for the target archetype.

        If not informed, it will be inferred from the Archetypes
        registry. That should be OK if the type didn't get renamed in
        the portal_types tool.""",
        required=False
        )

    factory = GlobalObject(
        title=u"Factory",
        description=u"""
        A callable (can be a class or function or something else) that
        creates a instance of the archetype, or a object that
        implements enough to be able to validate the schema.

        If one is not provided, we lookup the archetype class using
        the product and meta_type informed.
        """,
        required=False
        )

class IEditForm(ICommonInformation):
    """Form for editing an archetype
    """
