Ejemplo n.º 1
0
class IProductReleaseFilePublic(Interface):
    """Public properties for `IProductReleaseFile`."""

    id = Int(title=_('ID'), required=True, readonly=True)
    productrelease = exported(
        ReferenceChoice(title=_('Project release'),
                        description=_("The parent product release."),
                        schema=Interface,  # Defined later.
                        required=True,
                        vocabulary='ProductRelease'),
        exported_as='project_release')
    libraryfile = exported(
        Bytes(title=_("File"),
              description=_("The file contents."),
              readonly=True,
              required=True),
        exported_as='file')
    signature = exported(
        Bytes(title=_("File signature"),
              description=_("The file signature."),
              readonly=True,
              required=False))
    filetype = exported(
        Choice(title=_("Upstream file type"), required=True,
               vocabulary=UpstreamFileType,
               default=UpstreamFileType.CODETARBALL),
        exported_as='file_type')
    description = exported(
        Text(title=_("Description"), required=False,
             description=_('A detailed description of the file contents')))
    date_uploaded = exported(
        Datetime(title=_('Upload date'),
                 description=_('The date this file was uploaded'),
                 required=True, readonly=True))
Ejemplo n.º 2
0
    def __init__(self, default_image_resource=None, **kw):
        # 'default_image_resource' is a keyword argument so that the
        # class constructor can be used in the same way as other
        # Interface attribute specifiers.
        if default_image_resource is None:
            raise AssertionError("You must specify a default image resource.")

        self.default_image_resource = default_image_resource
        Bytes.__init__(self, **kw)
Ejemplo n.º 3
0
    def __init__(self, default_image_resource=None, **kw):
        # 'default_image_resource' is a keyword argument so that the
        # class constructor can be used in the same way as other
        # Interface attribute specifiers.
        if default_image_resource is None:
            raise AssertionError(
                "You must specify a default image resource.")

        self.default_image_resource = default_image_resource
        Bytes.__init__(self, **kw)
Ejemplo n.º 4
0
class ISchemaTest(Interface):
    title = Bytes(title=u"Title",
                  description=u"Title",
                  default="",
                  required=True)

    description = Bytes(title=u"Description",
                        description=u"Description",
                        default="",
                        required=True)

    spam = Bytes(title=u"Spam", description=u"Spam", default="", required=True)
Ejemplo n.º 5
0
 class ISchemaTest(Interface):
     title = Bytes(title=u("Title"),
                   description=u("Title"),
                   default=b(""),
                   required=True)
     description = Bytes(title=u("Description"),
                         description=u("Description"),
                         default=b(""),
                         required=True)
     spam = Bytes(title=u("Spam"),
                  description=u("Spam"),
                  default=b(""),
                  required=True)
Ejemplo n.º 6
0
 def test_w_fields(self):
     from zope.schema import Text
     from zope.schema import Bytes
     from zope.schema import Int
     from zope.schema import Float
     from zope.schema import Decimal
     self.assertEqual(self._callFUT([Text()]), True)
     self.assertEqual(self._callFUT([Bytes()]), True)
     self.assertEqual(self._callFUT([Int()]), True)
     self.assertEqual(self._callFUT([Float()]), True)
     self.assertEqual(self._callFUT([Decimal()]), True)
     self.assertEqual(self._callFUT(
                          [Text(), Bytes(), Int(), Float(), Decimal()]),
                      True)
Ejemplo n.º 7
0
class IDiff(Interface):
    """A diff that is stored in the Library."""

    text = Text(
        title=_('Textual contents of a diff.'),
        readonly=True,
        description=_("The text may be cut off at a defined maximum size."))

    oversized = Bool(
        readonly=True,
        description=_(
            "True if the size of the content is over the defined maximum "
            "size."))

    diff_text = exported(
        Bytes(title=_('Content of this diff'), required=True, readonly=True))

    diff_lines_count = exported(
        Int(title=_('The number of lines in this diff.'), readonly=True))

    diffstat = exported(
        Dict(title=_('Statistics about this diff'), readonly=True))

    added_lines_count = exported(
        Int(title=_('The number of lines added in this diff.'), readonly=True))

    removed_lines_count = exported(
        Int(title=_('The number of lines removed in this diff.'),
            readonly=True))
Ejemplo n.º 8
0
class IGSCreateUserCSV(Interface):
    csvFile = Bytes(
        title=u'CSV File',
        description=u'The comma-separated value file that contains the '
        u'membership information you wish to load.',
        required=True,
        default=None)
Ejemplo n.º 9
0
class IFile(IAttributeAnnotatable):
    """File object interface"""

    content_type = BytesLine(title="Content type",
                             description="The content type identifies the type of content data",
                             required=False,
                             default=b'',
                             missing_value=b'')

    data = Bytes(title="Content data",
                 description="Actual file content",
                 required=False,
                 default=b'',
                 missing_value=b'')

    def get_size(self):
        """Returns the byte-size of object's data"""

    def get_blob(self, mode='r'):
        """Get Blob file associated with this object"""

    def add_blob_reference(self, reference):
        """Add a reference to file internal blob"""

    def free_blob(self):
        """Free blob associated with this object"""
Ejemplo n.º 10
0
class IEasyFormImportFormSchema(Interface):

    """Schema for easyform import form.
    """
    upload = Bytes(
        title=PMF(u'Upload'),
        required=True)
Ejemplo n.º 11
0
class IProductReleaseFileAddForm(Interface):
    """Schema for adding ProductReleaseFiles to a project."""
    description = Text(title=_("Description"), required=True,
        description=_('A short description of the file contents'))

    filecontent = Bytes(
        title=u"File", required=True,
        constraint=productrelease_file_size_constraint)

    signature = Bytes(
        title=u"GPG signature (recommended)", required=False,
        constraint=productrelease_signature_size_constraint)

    contenttype = Choice(title=_("File content type"), required=True,
                         vocabulary=UpstreamFileType,
                         default=UpstreamFileType.CODETARBALL)
Ejemplo n.º 12
0
class IDocumentSchema(Interface):

    """Schema for document views.
    """

    safety_belt = ASCIILine(
        required=False)

    title = TextLine(
        title=_(u'Title'),
        readonly=True)

    description = Text(
        title=_(u'Description'),
        readonly=True)

    text_format = Choice(
        title=_(u'Format'),
        vocabulary='cmf.AvailableTextFormats')

    upload = Bytes(
        title=_(u'Upload'),
        required=False)

    text = Text(
        title=_(u'Body'),
        required=False,
        missing_value=u'')
Ejemplo n.º 13
0
class IFavicon(Interface):
    """A favicon."""

    path = TextLine(
        title=u"The name of the file containing the favicon data.",
        required=True)
    data = Bytes(title=u"The favicon data.", required=True)
Ejemplo n.º 14
0
class IBugAddForm(IBug):
    """Information we need to create a bug"""
    id = Int(title=_("Bug #"), required=False)
    product = Choice(title=_("Project"),
                     required=False,
                     description=_("""The thing you found this bug in,
            which was installed by something other than apt-get, rpm,
            emerge or similar"""),
                     vocabulary="Product")
    packagename = Choice(title=_("Package Name"),
                         required=False,
                         description=_("""The package you found this bug in,
            which was installed via apt-get, rpm, emerge or similar."""),
                         vocabulary="BinaryAndSourcePackageName")
    title = Title(title=_('Summary'), required=True)
    distribution = Choice(
        title=_("Linux Distribution"),
        required=True,
        description=_("Ubuntu, Debian, Gentoo, etc. You can file bugs only on "
                      "distrubutions using Launchpad as their primary bug "
                      "tracker."),
        vocabulary="DistributionUsingMalone")
    owner = Int(title=_("Owner"), required=True)
    comment = Description(title=_('Further information'),
                          strip_text=True,
                          trailing_only=True,
                          min_length=1,
                          max_length=50000,
                          required=False)
    bug_already_reported_as = Choice(
        title=_("This bug has already been reported as ..."),
        required=False,
        vocabulary="Bug")
    filecontent = Bytes(title=u"Attachment",
                        required=False,
                        constraint=attachment_size_constraint)
    patch = Bool(title=u"This attachment is a patch",
                 required=False,
                 default=False)
    attachment_description = Title(title=u'Description', required=False)
    status = Choice(title=_('Status'),
                    values=list(item for item in BugTaskStatus.items.items
                                if item != BugTaskStatus.UNKNOWN),
                    default=IBugTask['status'].default)
    importance = Choice(title=_('Importance'),
                        values=list(item
                                    for item in BugTaskImportance.items.items
                                    if item != BugTaskImportance.UNKNOWN),
                        default=IBugTask['importance'].default)
    milestone = Choice(title=_('Milestone'),
                       required=False,
                       vocabulary='Milestone')
    assignee = PublicPersonChoice(title=_('Assign to'),
                                  required=False,
                                  vocabulary='ValidAssignee')
    subscribe_to_existing_bug = Choice(title=u'Subscribe to this bug',
                                       vocabulary=SUBSCRIBE_TO_BUG_VOCABULARY,
                                       required=True,
                                       default=False)
Ejemplo n.º 15
0
class IImportSchema(Interface):
    """Schema for form import.
    """
    upload = Bytes(title=_(u'Upload'), required=True)

    purge = Bool(title=_(u'Remove Existing Form Items?'),
                 default=False,
                 required=False)
Ejemplo n.º 16
0
class IJobInfo(Interface):
    """Job interface"""

    id = TextLine(title="Job ID")

    next_run_time = Float(title="Job next run time")

    job_state = Bytes(title="Job state")
Ejemplo n.º 17
0
class IImportXlsData(Interface):
    """Interface for all Objects"""
    xlsdata = Bytes(title=_("XLS data"), required=True)

    codepage = Choice(title=_("Codepage"),
                      description=_("Codepage of XLS"),
                      vocabulary="AllXlsCodepages",
                      default='cp850',
                      required=True)
Ejemplo n.º 18
0
 def test_w_mixed(self):
     from zope.schema import Text
     from zope.schema import Bytes
     from zope.schema import Int
     from zope.schema import Float
     from zope.schema import Decimal
     self.assertEqual(self._callFUT([Text(), 0]), False)
     self.assertEqual(self._callFUT(
                          [Text(), Bytes(), Int(), Float(), Decimal(), 0]),
                      False)
Ejemplo n.º 19
0
class IRevisionMailJob(IRunnableJob):
    """A Job to send email a revision change in a branch."""

    revno = Int(title=u'The revno to send mail about.')

    from_address = Bytes(title=u'The address to send mail from.')

    body = Text(title=u'The main text of the email to send.')

    subject = Text(title=u'The subject of the email to send.')
Ejemplo n.º 20
0
 def test_w_normal_fields(self):
     from zope.schema import Text
     from zope.schema import Bytes
     from zope.schema import Int
     from zope.schema import Float
     from zope.schema import Decimal
     self.assertEqual(self._callFUT(Text()), True)
     self.assertEqual(self._callFUT(Bytes()), True)
     self.assertEqual(self._callFUT(Int()), True)
     self.assertEqual(self._callFUT(Float()), True)
     self.assertEqual(self._callFUT(Decimal()), True)
Ejemplo n.º 21
0
class IFileSchema(Interface):
    """Schema for file views.
    """

    title = TextLine(title=_(u'Title'), readonly=True)

    description = Text(title=_(u'Description'), readonly=True)

    format = ASCIILine(title=_(u'Content type'), readonly=True)

    upload = Bytes(title=_(u'Upload'), required=False)
Ejemplo n.º 22
0
class ISiteSchema(IBaseSiteSchema):

    show_header_text = Bool(
        title=_(u'Display text in Header'),
        description=_(
            u'Displays site title and description on every site pages.'),
        required=False,
        default=True)

    image = Bytes(title=_(u'Imagem do Logo'),
                  description=_(u'Insira nesse campo o logo do tema local'),
                  required=False)

    show_header_logo = Bool(title=_(u'Display logo in Header'),
                            description=_(u''),
                            required=False,
                            default=True)

    background = Bytes(title=_(u'Header background image'),
                       description=_(u''),
                       required=False)
Ejemplo n.º 23
0
class IProductReleaseEditRestricted(Interface):
    """`IProductRelease` properties which require `launchpad.Edit`."""

    @call_with(uploader=REQUEST_USER, from_api=True)
    @operation_parameters(
        filename=TextLine(),
        signature_filename=TextLine(),
        content_type=TextLine(),
        file_content=Bytes(constraint=productrelease_file_size_constraint),
        signature_content=Bytes(
            constraint=productrelease_signature_size_constraint),
        file_type=copy_field(IProductReleaseFile['filetype'], required=False))
    @export_factory_operation(IProductReleaseFile, ['description'])
    @export_operation_as('add_file')
    def addReleaseFile(filename, file_content, content_type,
                       uploader, signature_filename=None,
                       signature_content=None,
                       file_type=UpstreamFileType.CODETARBALL,
                       description=None, from_api=False):
        """Add file to the library and link to this `IProductRelease`.

        The signature file will also be added if available.

        :param filename: Name of the file being uploaded.
        :param file_content: StringIO or file object.
        :param content_type: A MIME content type string.
        :param uploader: The person who uploaded the file.
        :param signature_filename: Name of the uploaded gpg signature file.
        :param signature_content: StringIO or file object.
        :param file_type: An `UpstreamFileType` enum value.
        :param description: Info about the file.
        :returns: `IProductReleaseFile` object.
        :raises: InvalidFilename if the filename is invalid or a duplicate
            of a file previously added to the release.
        """

    @export_write_operation()
    @export_operation_as('delete')
    def destroySelf():
        """Delete this release.
class ICsv(Interface):
    """Schema for parsing a CSV file."""
    csv = Bytes(title='CSV File',
                description='The CSV file to be processed.',
                required=True)

    # TODO: Check for the required attributes
    columns = List(title='Columns',
                   description='The columns in the CSV.',
                   value_type=Choice(title='Profile attribute',
                                     vocabulary='ProfileAttributes'),
                   unique=True,
                   required=True)
Ejemplo n.º 25
0
    def test_widget(self):
        field = Bytes(__name__='foo', missing_value=None, required=False)
        request = TestRequest(form={'field.foo': u''})
        widget = ImageWidget(field, request)

        self.assertTrue(widget.getInputValue() is None)

        request = TestRequest(form={
            'field.foo': u'',
            'field.foo.action': u'remove'
        })
        widget = ImageWidget(field, request)

        self.assertTrue(widget.getInputValue() == 'remove')
        self.assertTrue(widget() == RENDERED)
Ejemplo n.º 26
0
class IDistroArchSeriesModerate(Interface):

    @operation_parameters(data=Bytes(), sha1sum=Text())
    @export_write_operation()
    @operation_for_version("devel")
    def setChroot(data, sha1sum):
        """Set the chroot tarball used for builds in this architecture.

        The SHA-1 checksum must match the chroot file.
        """

    @export_write_operation()
    @operation_for_version("devel")
    def removeChroot():
        """Remove the chroot tarball used for builds in this architecture."""
Ejemplo n.º 27
0
class IDistroArchSeriesModerate(Interface):
    @operation_parameters(data=Bytes(),
                          sha1sum=Text(),
                          pocket=Choice(vocabulary=PackagePublishingPocket,
                                        required=False),
                          image_type=Choice(vocabulary=BuildBaseImageType,
                                            required=False))
    @export_write_operation()
    @operation_for_version("devel")
    def setChroot(data, sha1sum, pocket=None, image_type=None):
        """Set the chroot tarball used for builds in this architecture.

        The SHA-1 checksum must match the chroot file.

        The pocket defaults to "Release"; the image type defaults to "Chroot
        tarball".
        """

    @operation_parameters(
        # Really ILiveFSBuild, patched in _schema_circular_imports.py.
        livefsbuild=Reference(Interface,
                              title=_("Live filesystem build"),
                              required=True),
        filename=TextLine(title=_("Filename"), required=True),
        pocket=Choice(vocabulary=PackagePublishingPocket, required=False),
        image_type=Choice(vocabulary=BuildBaseImageType, required=False))
    @export_write_operation()
    @operation_for_version("devel")
    def setChrootFromBuild(livefsbuild,
                           filename,
                           pocket=None,
                           image_type=None):
        """Set the chroot tarball from a live filesystem build.

        The pocket defaults to "Release"; the image type defaults to "Chroot
        tarball".
        """

    @operation_parameters(pocket=Choice(vocabulary=PackagePublishingPocket,
                                        required=False),
                          image_type=Choice(vocabulary=BuildBaseImageType,
                                            required=False))
    @export_write_operation()
    @operation_for_version("devel")
    def removeChroot(pocket=None, image_type=None):
        """Remove the chroot tarball used for builds in this architecture.
class IGSPostMessage(Interface):
    fromAddress = Choice(title=_('from-address', 'Email from'),
                         description=_(
                             'from-address-help',
                             'The email address that you want in the "From" '
                             'line in the email you send.'),
                         vocabulary='EmailAddressesForLoggedInUser',
                         required=True)

    message = Text(title=_('message', 'Message'),
                   description=_(
                       'message-help',
                       'The message you want to post to this topic.'),
                   required=True)

    uploadedFile = Bytes(title='Files',
                         description='A file you wish to add.',
                         required=False)
Ejemplo n.º 29
0
class IFile(Interface):

    contentType = BytesLine(
        title=_(u'Content Type'),
        description=_(u'The content type identifies the type of data.'),
        default='',
        required=False,
        missing_value='')

    data = Bytes(
        title=_(u'Data'),
        description=_(u'The actual content of the object.'),
        default='',
        missing_value='',
        required=False,
    )

    def getSize():
        """Return the byte-size of the data of the object."""
Ejemplo n.º 30
0
class IX509Certificate(Interface):
    """A X509Certificate object."""
    publicKey = Text(
        max_length = 4000,
        title = _("public key (PEM)"),
        description = _("The PEM-encoded raw public key."),
        required = True)

    ddd1 = Bytes(
         title = u'ddd1')

    @invariant
    def ensureValidPublicKey(obj_x509):
        """publicKey must be valid PEM string
        """
        try:
            crypto.load_certificate(crypto.FILETYPE_PEM, obj_x509.publicKey)
        except crypto.Error, errText:
            raise Invalid(u'Invalid public key: %s' % errText)
Ejemplo n.º 31
0
class IInternalAttachment(Interface):
    """A InternalAttachment object."""

    filename = TextLine(title=_(u'filename'),
                        description=_(u"long description text line"),
                        required=False)

    contentType = TextLine(title=_(u'content type'),
                           description=_(u"long description choice"),
                           required=False)

    data = Bytes(title=_(u'data'),
                 description=_(u"long description date"),
                 required=False)

    file = Attribute("file")

    def trigger_online():
        """
Ejemplo n.º 32
0
 def set(self, object, value):
     if value is not KEEP_SAME_IMAGE:
         Bytes.set(self, object, value)