Skip to content
Permalink
Browse files

Remove __getattr__, __setattr__ for QgsFeature

Not such a good idea after all :)
  • Loading branch information
NathanW2 committed Jul 9, 2013
1 parent 3932a51 commit 0bb954327895a3bf0feb7167bac2b998aa30ab0d
Showing with 0 additions and 83 deletions.
  1. +0 −83 python/core/qgsfeature.sip
@@ -116,89 +116,6 @@ class QgsFeature

public:

SIP_PYOBJECT __getattr__(const QString& name);
%MethodCode
int fieldIdx = sipCpp->fieldNameIndex(*a0);
QString altname = QString(*a0).replace("_"," ");
int altfieldIdx = sipCpp->fieldNameIndex(altname);

if (fieldIdx >= 0)
{
QVariant v = sipCpp->attribute(fieldIdx);
if ( v.isNull() )
{
Py_INCREF( Py_None );
sipRes = Py_None;
}
else
sipRes = sipConvertFromType( &v, sipType_QVariant, Py_None );
}
else if( altfieldIdx >= 0 )
{
QVariant v = sipCpp->attribute(altfieldIdx);
if ( v.isNull() )
{
Py_INCREF( Py_None );
sipRes = Py_None;
}
else
sipRes = sipConvertFromType( &v, sipType_QVariant, Py_None );
}
else
{
PyObject* key = PyString_FromString(a0->toStdString().c_str());
sipRes = PyObject_GenericGetAttr(sipSelf, key );
}
%End

void __setattr__(const QString& key, QVariant value /GetWrapper/);
%MethodCode
int fieldIdx = sipCpp->fieldNameIndex(*a0);
QString altname = QString(*a0).replace("_"," ");
int altfieldIdx = sipCpp->fieldNameIndex(altname);

if (fieldIdx >= 0)
{
if ( a1Wrapper == Py_None )
{
sipCpp->setAttribute(fieldIdx, QVariant( QVariant::Int ) );
}
else
{
sipCpp->setAttribute(fieldIdx, *a1);
}
}
else if( altfieldIdx >= 0 )
{
if ( a1Wrapper == Py_None )
{
sipCpp->setAttribute(altfieldIdx, QVariant( QVariant::Int ) );
}
else
{
sipCpp->setAttribute(altfieldIdx, *a1);
}
}
else
{
PyObject* key = PyString_FromString(a0->toStdString().c_str());
PyObject* value = sipConvertFromType( a1, sipType_QVariant, sipSelf);
PyObject_GenericSetAttr(sipSelf, key, value);
}
%End

void __delattr__(const QString& key);
%MethodCode
int fieldIdx = sipCpp->fieldNameIndex(*a0);
if (fieldIdx == -1)
{
PyErr_SetString(PyExc_KeyError, a0->toAscii());
sipIsErr = 1;
}
else
sipCpp->deleteAttribute(fieldIdx);
%End

SIP_PYOBJECT __getitem__(int key);
%MethodCode
const QgsAttributes& attrs = sipCpp->attributes();

0 comments on commit 0bb9543

Please sign in to comment.
You can’t perform that action at this time.