cBook* pBook = dynamic_cast< cBook* >(self->pItem); if( pBook ) { QStringList content = pBook->content(); QStringList::iterator it = content.begin(); PyObject *list = PyList_New( content.size() ); UINT32 i = 0; while( it != content.end() ) { PyList_SetItem( list, i, PyString_FromString( *it ) ); ++it; ++i; } return list; }
static PyObject *wpItem_getAttr( wpItem *self, char *name ){	// Special Python things	if( !strcmp( "content", name ) )	{			cBook* pBook = dynamic_cast< cBook* >(self->pItem);		if( pBook )		{			QStringList content = pBook->content();			QStringList::iterator it = content.begin();			PyObject *list = PyList_New( content.size() );			UINT32 i = 0;			while( it != content.end() )			{				PyList_SetItem( list, i, PyString_FromString( *it ) );				++it;				++i;			}			return list;		}		cItem::ContainerContent content = self->pItem->content();		PyObject *list = PyList_New( content.size() );		for( INT32 i = 0; i < content.size(); ++i )			PyList_SetItem( list, i, PyGetItemObject( content[i] ) );				return list;	}	else if( !strcmp( "events", name ) )	{		QStringList events = QStringList::split( ",", self->pItem->eventList() );		PyObject *list = PyList_New( events.count() );		for( INT32 i = 0; i < events.count(); ++i )			PyList_SetItem( list, i, PyString_FromString( events[i].latin1() ) );		return list;	}	else	{		cVariant result;		stError *error = self->pItem->getProperty( name, result );		if( !error )		{			PyObject *obj = 0;			switch( result.type() )			{			case cVariant::BaseChar:				obj = PyGetCharObject( result.toChar() );				break;			case cVariant::Item:				obj = PyGetItemObject( result.toItem() );				break;			case cVariant::Long:			case cVariant::Int:				obj = PyInt_FromLong( result.toInt() );				break;			case cVariant::String:				if( result.toString().isNull() )					obj = PyString_FromString( "" );				else					obj = PyString_FromString( result.toString().latin1() );				break;			case cVariant::Double:				obj = PyFloat_FromDouble( result.toDouble() );				break;			case cVariant::Coord:				obj = PyGetCoordObject( result.toCoord() );				break;			}			if( !obj )			{				PyErr_Format( PyExc_ValueError, "Unsupported Property Type: %s", result.typeName() );				return 0;			}			return obj;		}		else			delete error;	}			return Py_FindMethod( wpItemMethods, (PyObject*)self, name );}