def testTag(self): provideAdapter(StubAbsoluteURL) image = Image() fe = ImageData() fe.context = image fe.request = FakeRequest() self.assertEqual( fe.tag(), '<img src="/img" alt="" height="-1" width="-1" border="0" />') self.assertEqual( fe.tag(scale=.9, width=10, height=10), '<img src="/img" alt="" height="9" width="9" border="0" />') self.assertEqual( fe.tag(alt="Test Image"), '<img src="/img" alt="Test Image"' ' height="-1" width="-1" border="0" />') self.assertEqual( fe.tag(height=100, width=100), '<img src="/img" alt="" height="100" width="100" border="0" />') self.assertEqual( fe.tag(border=1), '<img src="/img" alt="" height="-1" width="-1" border="1" />') self.assertEqual( fe.tag(css_class="Image"), '<img src="/img" alt=""' ' height="-1" width="-1" border="0" class="Image" />') self.assertEqual( fe.tag(height=100, width="100", border=1, css_class="Image"), '<img src="/img" alt=""' ' height="100" width="100" class="Image" border="1" />')
def _getFormInput(self): filedata = self.request.get(self.name) delete = self.request.has_key(self.name + '.delete') if delete: return None else: if not filedata: # formlib does not adapt the context if render_context # is set to false. so we have no valid context and a # ForbiddenAttribute error is thrown. try: return self.context.get(self.context.context) except ForbiddenAttribute: return None else: fileObj = Image(filedata) zope.event.notify(ObjectCreatedEvent(fileObj)) return fileObj
def _makeFile(self, *args, **kw): return Image(*args, **kw)
def addImage(self): image = Image(self.content) root = self.getRootFolder() root['image'] = image self.commit()
def testData(self): image = Image(b'Data') data = ImageData() data.context = image data.request = None self.assertEqual(data(), b'Data')
def testData(self): image = Image('Data') id = ImageData() id.context = image id.request = None self.assertEqual(id(), 'Data')