[GRASS-dev] g.mapsets, print only accessible mapsets

Hi all,

is there a way how to determine if a mapset is accessible without need
to switch 'g.mapset name' -> 'ERROR: You don't have permission to use
this mapset'. If not maybe new flag for g.mapsets would make sense?

-a 'List all accessible mapsets'

Martin

--
Martin Landa <landa.martin gmail.com> * http://gama.fsv.cvut.cz/~landa *

Martin,

in libgis I see
/****************************************************************
* G__mapset_permissions (mapset)
*
* returns: 1 mapset exists, and user has permission
* 0 mapset exists, BUT user denied permission
* -1 mapset does not exist
****************************************************************/

could that help (in modified form)?

Markus

On Thu, Mar 20, 2008 at 2:49 PM, Martin Landa <landa.martin@gmail.com> wrote:

Hi all,

is there a way how to determine if a mapset is accessible without need
to switch 'g.mapset name' -> 'ERROR: You don't have permission to use
this mapset'. If not maybe new flag for g.mapsets would make sense?

-a 'List all accessible mapsets'

Martin

--
Martin Landa <landa.martin gmail.com> * http://gama.fsv.cvut.cz/~landa *
_______________________________________________
grass-dev mailing list
grass-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-dev

--
Open Source Geospatial Foundation
http://www.osgeo.org/
http://www.grassbook.org/

Markus,

2008/3/20, Markus Neteler <neteler@osgeo.org>:

in libgis I see
/****************************************************************
* G__mapset_permissions (mapset)
*
* returns: 1 mapset exists, and user has permission
* 0 mapset exists, BUT user denied permission
* -1 mapset does not exist
****************************************************************/

could that help (in modified form)?

I need list of accessible mapsets for wxGUI welcome screen (currently
'g.mapsets -l' is used which prints all available mapsets). Modifying
g.mapsets module to print only accessible mapsets would be pretty easy
(aka new flag), BTW how TCL/TK checks if mapsets is accessible (I see
that those mapsets are hidden in welcome screen)?

Martin

--
Martin Landa <landa.martin gmail.com> * http://gama.fsv.cvut.cz/~landa *

In TclTk it's done simply by listing all directories owned by user -

lib/init/gis_set.tcl:
foreach i [lsort [glob -directory [pwd] *]] {
if {[file isdirectory $i] && [file owned $i] } {
$mapList insert end [file tail $i]

Maris.

2008/3/20, Martin Landa <landa.martin@gmail.com>:

Markus,
BTW how TCL/TK checks if mapsets is accessible (I see
that those mapsets are hidden in welcome screen)?

Martin

--
Martin Landa <landa.martin gmail.com> * http://gama.fsv.cvut.cz/~landa *

Martin Landa wrote:

Hi all,

is there a way how to determine if a mapset is accessible without need
to switch 'g.mapset name' -> 'ERROR: You don't have permission to use
this mapset'. If not maybe new flag for g.mapsets would make sense?

-a 'List all accessible mapsets'

At the C level, G__mapset_permissions() and G__mapset_permissions2()
determines whether or not a specific mapset can be used as the current
mapset (i.e. it's a directory, and you own it).

AFAIK, there isn't a user command to determine this. If it's useful,
it really belongs in g.mapset rather than g.mapsets, as the former
deals with the current mapset (used for output) while the latter deals
with the mapsets used for input.

--
Glynn Clements <glynn@gclements.plus.com>

Hi,

2008/3/20, Glynn Clements <glynn@gclements.plus.com>:

> is there a way how to determine if a mapset is accessible without need
> to switch 'g.mapset name' -> 'ERROR: You don't have permission to use
> this mapset'. If not maybe new flag for g.mapsets would make sense?
>
> -a 'List all accessible mapsets'

At the C level, G__mapset_permissions() and G__mapset_permissions2()
determines whether or not a specific mapset can be used as the current
mapset (i.e. it's a directory, and you own it).

AFAIK, there isn't a user command to determine this. If it's useful,
it really belongs in g.mapset rather than g.mapsets, as the former
deals with the current mapset (used for output) while the latter deals
with the mapsets used for input.

I think it would be useful, at least for creating list of mapsets in
GUI start-up screen. Currently is used 'g.mapsets -l' which prints all
mapsets in the location. I don't fully understand here, why g.mapsets
is not good place for that.

g.mapsets -l -> prints *all* mapsets
g.mapsets -a -> print only *accessible* mapset

At least this would be useful for GUI start-up screen (to disable not
accessible mapsets).

Martin

--
Martin Landa <landa.martin gmail.com> * http://gama.fsv.cvut.cz/~landa *

Markus:

in libgis I see
/****************************************************************
* G__mapset_permissions (mapset)
*
* returns: 1 mapset exists, and user has permission
* 0 mapset exists, BUT user denied permission
* -1 mapset does not exist
****************************************************************/

it would be nice to have inaccessible mapsets listed in the GUI mapset
selection box, but greyed out.

away until next week,
Hamish

      ____________________________________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ

Hi,

2008/3/20, Hamish <hamish_b@yahoo.com>:

Markus:

> in libgis I see
> /****************************************************************
> * G__mapset_permissions (mapset)
> *
> * returns: 1 mapset exists, and user has permission
> * 0 mapset exists, BUT user denied permission
> * -1 mapset does not exist
> ****************************************************************/

it would be nice to have inaccessible mapsets listed in the GUI mapset
selection box, but greyed out.

yes, that's what I would like to implement, combination of `g.mapsets
-l` and `g.mapsets -a` could be a solution.

Martin

--
Martin Landa <landa.martin gmail.com> * http://gama.fsv.cvut.cz/~landa *

Martin Landa wrote:

> > is there a way how to determine if a mapset is accessible without need
> > to switch 'g.mapset name' -> 'ERROR: You don't have permission to use
> > this mapset'. If not maybe new flag for g.mapsets would make sense?
> >
> > -a 'List all accessible mapsets'
>
> At the C level, G__mapset_permissions() and G__mapset_permissions2()
> determines whether or not a specific mapset can be used as the current
> mapset (i.e. it's a directory, and you own it).
>
> AFAIK, there isn't a user command to determine this. If it's useful,
> it really belongs in g.mapset rather than g.mapsets, as the former
> deals with the current mapset (used for output) while the latter deals
> with the mapsets used for input.

I think it would be useful, at least for creating list of mapsets in
GUI start-up screen. Currently is used 'g.mapsets -l' which prints all
mapsets in the location. I don't fully understand here, why g.mapsets
is not good place for that.

"g.mapsets -l" displays a list of mapsets which are suitable for use
as values in g.mapsets' mapset= and addmapset= options.

You are essentially asking about mapsets which are suitable for use as
values in the mapset= option of g.mapset[1]. The logical place for
such an option is in g.mapset.

[1] init.sh/init.bat have their own built-in clone of g.mapset. It
would be worth looking into whether they can be changed to use
g.mapset instead.

There is a great deal of asymmetry between output and input; the
current mapset and the mapset search path are really very different
entities. g.mapset deals exclusively with the former, g.mapsets deals
exclusively with the latter.

And the option which you're proposing is related to the former.

g.mapsets -l -> prints *all* mapsets
g.mapsets -a -> print only *accessible* mapset

"accessible" is the wrong word here. You can "access" any mapset for
which you have read permission.

--
Glynn Clements <glynn@gclements.plus.com>

Hi,

the attached patch adds to g.mapset module new flag '-l' (print
available mapsets with write permission). It requires dummy value for
mapset, e.g.

g.mapset -l map=dummy

same story like `r.in.gdal -f` and others. It would be reasonable to
introduce new attribute in option/flag structure, something like
'suppress_required'. The value could be global (YES/NO), to suppress
all required flags/options or better list of option/flags (e.g. their
keys) which are required and will be suppressed by the given
flag/option.

Regards, Martin

2008/3/21, Glynn Clements <glynn@gclements.plus.com>:

Martin Landa wrote:

> > > is there a way how to determine if a mapset is accessible without need
> > > to switch 'g.mapset name' -> 'ERROR: You don't have permission to use
> > > this mapset'. If not maybe new flag for g.mapsets would make sense?
> > >
> > > -a 'List all accessible mapsets'
> >
> > At the C level, G__mapset_permissions() and G__mapset_permissions2()
> > determines whether or not a specific mapset can be used as the current
> > mapset (i.e. it's a directory, and you own it).
> >
> > AFAIK, there isn't a user command to determine this. If it's useful,
> > it really belongs in g.mapset rather than g.mapsets, as the former
> > deals with the current mapset (used for output) while the latter deals
> > with the mapsets used for input.
>
> I think it would be useful, at least for creating list of mapsets in
> GUI start-up screen. Currently is used 'g.mapsets -l' which prints all
> mapsets in the location. I don't fully understand here, why g.mapsets
> is not good place for that.

"g.mapsets -l" displays a list of mapsets which are suitable for use
as values in g.mapsets' mapset= and addmapset= options.

You are essentially asking about mapsets which are suitable for use as
values in the mapset= option of g.mapset[1]. The logical place for
such an option is in g.mapset.

[1] init.sh/init.bat have their own built-in clone of g.mapset. It
would be worth looking into whether they can be changed to use
g.mapset instead.

There is a great deal of asymmetry between output and input; the
current mapset and the mapset search path are really very different
entities. g.mapset deals exclusively with the former, g.mapsets deals
exclusively with the latter.

And the option which you're proposing is related to the former.

> g.mapsets -l -> prints *all* mapsets
> g.mapsets -a -> print only *accessible* mapset

"accessible" is the wrong word here. You can "access" any mapset for
which you have read permission.

--

Glynn Clements <glynn@gclements.plus.com>

--
Martin Landa <landa.martin gmail.com> * http://gama.fsv.cvut.cz/~landa *

(attachments)

g-mapset-l.diff (1.33 KB)

Martin Landa wrote:

the attached patch adds to g.mapset module new flag '-l' (print
available mapsets with write permission). It requires dummy value for
mapset, e.g.

g.mapset -l map=dummy

I've committed the patch, but changed mapset_opt->required to NO.

same story like `r.in.gdal -f` and others. It would be reasonable to
introduce new attribute in option/flag structure, something like
'suppress_required'. The value could be global (YES/NO), to suppress
all required flags/options or better list of option/flags (e.g. their
keys) which are required and will be suppressed by the given
flag/option.

Initially, it should just be global, i.e. the switch can be used on
its own, with no other options required.

Anything more involved than that should be part of an overall redesign
of "required" options, e.g. option groups.

However, I'm not sure that even the simplest version should go into
6.3, the critical nature of the parser.

--
Glynn Clements <glynn@gclements.plus.com>

Hi,

2008/3/24, Glynn Clements <glynn@gclements.plus.com>:

I've committed the patch, but changed mapset_opt->required to NO.

thanks, small issue here -- the '-l' flag ignores gisdbase= and
location= parameters, it always prints list of mapsets for the
*current* location. The attached patch should fix it. If you have no
objections I will applied in trunk.

Martin

--
Martin Landa <landa.martin gmail.com> * http://gama.fsv.cvut.cz/~landa *

(attachments)

g_available_mapsets2.diff (3.01 KB)

Martin Landa wrote:

2008/3/24, Glynn Clements <glynn@gclements.plus.com>:
> I've committed the patch, but changed mapset_opt->required to NO.

thanks, small issue here -- the '-l' flag ignores gisdbase= and
location= parameters, it always prints list of mapsets for the
*current* location. The attached patch should fix it. If you have no
objections I will applied in trunk.

I'm not sure that a separate function with gisdbase/location arguments
is necessary. It is sufficient for g.mapset to just change those
settings with G__setenv().

--
Glynn Clements <glynn@gclements.plus.com>

Hi,

2008/3/25, Glynn Clements <glynn@gclements.plus.com>:

> thanks, small issue here -- the '-l' flag ignores gisdbase= and
> location= parameters, it always prints list of mapsets for the
> *current* location. The attached patch should fix it. If you have no
> objections I will applied in trunk.

I'm not sure that a separate function with gisdbase/location arguments
is necessary. It is sufficient for g.mapset to just change those
settings with G__setenv().

applied in trunk

http://trac.osgeo.org/grass/changeset/30725

Martin
--
Martin Landa <landa.martin gmail.com> * http://gama.fsv.cvut.cz/~landa *