if (ret instanceof PyString) {
response.setEntity(ret.toString(), mediaType);
}
else if (ret instanceof PyList) {
final PyList list = (PyList) ret;
response.setEntity(new OutputRepresentation(mediaType) {
@Override
public void write(OutputStream outputStream) throws IOException {
for (Iterator i = list.iterator(); i.hasNext();) {
outputStream.write(i.next().toString().getBytes());
if (i.hasNext()) {
outputStream.write('\n');
}
}
}
});
}
else if (ret instanceof PyIterator) {
final PyIterator iter = (PyIterator) ret;
response.setEntity(new OutputRepresentation(mediaType) {
@Override
public void write(OutputStream outputStream) throws IOException {
for (Iterator i = iter.iterator(); i.hasNext();) {
outputStream.write(i.next().toString().getBytes());
outputStream.write('\n');
}
}
});
}
else if (ret instanceof PyObjectDerived) {
final PyObjectDerived iter = (PyObjectDerived)ret;
response.setEntity(new OutputRepresentation(mediaType) {
@Override
public void write(OutputStream outputStream) throws IOException {
PyObject next = null;
while ((next = iter.__iternext__()) != null) {