Make python ts rootDir appear as a read-only attribute
authorPanu Matilainen <pmatilai@redhat.com>
Thu, 1 Oct 2009 08:21:58 +0000 (11:21 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Thu, 1 Oct 2009 11:16:20 +0000 (14:16 +0300)
- there's no need to change the rootdir after object creation, better
  not permit at all

python/rpmts-py.c

index 3647662..8e069c1 100644 (file)
@@ -972,7 +972,6 @@ static PyObject * rpmts_new(PyTypeObject * subtype, PyObject *args, PyObject *kw
        return NULL;
 
     ts = rpmtsCreate();
-    /* XXX: Why is there no rpmts_SetRootDir() ? */
     (void) rpmtsSetRootDir(ts, rootDir);
     /* XXX: make this use common code with rpmts_SetVSFlags() to check the
      *      python objects */
@@ -986,6 +985,11 @@ static PyObject *rpmts_get_tid(rpmtsObject *s, void *closure)
     return Py_BuildValue("i", rpmtsGetTid(s->ts));
 }
 
+static PyObject *rpmts_get_rootDir(rpmtsObject *s, void *closure)
+{
+    return Py_BuildValue("s", rpmtsRootDir(s->ts));
+}
+
 static int rpmts_set_scriptFd(rpmtsObject *s, PyObject *value, void *closure)
 {
     int rc = 0;
@@ -1008,6 +1012,7 @@ static PyGetSetDef rpmts_getseters[] = {
        /* only provide a setter until we have rpmfd wrappings */
        {"scriptFd",    NULL,   (setter)rpmts_set_scriptFd, NULL },
        {"tid",         (getter)rpmts_get_tid, NULL, NULL },
+       {"rootDir",     (getter)rpmts_get_rootDir, NULL, NULL },
        { NULL }
 };