瀏覽代碼

pygrass: Create a link/table also when open a vector map in rw mode

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@66663 15284696-431f-4ddb-bdfa-cd5b030d7da7
Pietro Zambelli 9 年之前
父節點
當前提交
71d7a26eaf
共有 1 個文件被更改,包括 13 次插入12 次删除
  1. 13 12
      lib/python/pygrass/vector/abstract.py

+ 13 - 12
lib/python/pygrass/vector/abstract.py

@@ -352,18 +352,19 @@ class Info(object):
         if mode == 'w':
             openvect = libvect.Vect_open_new(self.c_mapinfo, self.name, with_z)
             self.dblinks = DBlinks(self.c_mapinfo)
-            if tab_cols:
-                # create a link
-                link = Link(layer,
-                            link_name if link_name else self.name,
-                            tab_name if tab_name else self.name,
-                            link_key, link_db, link_driver)
-                # add the new link
-                self.dblinks.add(link)
-                # create the table
-                table = link.table()
-                table.create(tab_cols)
-                table.conn.commit()
+
+        if mode in ('w', 'rw') and tab_cols:
+            # create a link
+            link = Link(layer,
+                        link_name if link_name else self.name,
+                        tab_name if tab_name else self.name,
+                        link_key, link_db, link_driver)
+            # add the new link
+            self.dblinks.add(link)
+            # create the table
+            table = link.table()
+            table.create(tab_cols)
+            table.conn.commit()
 
         # check the C function result.
         if openvect == -1: