Opened 11 years ago

Closed 11 years ago

#2330 closed defect (invalid)

Not all methods available in IronPython console

Reported by: ismael Owned by: jng
Priority: medium Milestone:
Component: Maestro Version: 2.4.0
Severity: major Keywords:
Cc: External ID:

Description

Some API methods are not available in the IronPython console. Especially the extension methods (e.g. IMapDefinition) are not available which make it sometimes hard to get a good result

Change History (3)

comment:2 by jng, 11 years ago

I just tried this in the IronPython console with IMapDefinition (which has some extension methods under the OSGeo.MapGuide.ObjectModels.MapDefinition namespace

IronPython 2.7.1 (2.7.0.40) on .NET 4.0.30319.18052
Type "help", "copyright", "credits" or "license" for more information.
>>> conn = app.GetConnection(app.GetConnectionNames()[0])
>>> import clr
>>> clr.AddReference("OSGeo.MapGuide.MaestroAPI")
>>> import OSGeo
>>> dir(OSGeo.MapGuide.ObjectModels.MapDefinition.IMapDefinition)
['AddGroup', 'AddLayer', 'BackgroundColor', 'BaseMap', 'Clone', 'CoordinateSystem', 'CurrentConnection', 'Extents', 'GetIndex', 'InitBaseMap', 'InsertLayer', 'IsStronglyTyped', 'MapLayer', 'MapLayerGroup', 'Metadata', 'MoveDown', 'MoveDownGroup', 'MoveUp', 'MoveUpGroup', 'Name', 'PropertyChanged', 'RemoveAllGroups', 'RemoveAllLayers', 'RemoveBaseMap', 'RemoveGroup', 'RemoveLayer', 'ResourceID', 'ResourceType', 'ResourceVersion', 'Serialize', 'SetBottomDrawOrder', 'SetExtents', 'SetExtentsFromFirstAddedLayer', 'SetTopDrawOrder', 'ValidatingSchema', '__doc__', '__repr__']
>>> clr.ImportExtensions(OSGeo.MapGuide.ObjectModels.MapDefinition)
>>> dir(OSGeo.MapGuide.ObjectModels.MapDefinition.IMapDefinition)
['AddGroup', 'AddLayer', 'BackgroundColor', 'BaseMap', 'Clone', 'CoordinateSystem', 'CurrentConnection', 'Extents', 'GetGroupByName', 'GetGroupCount', 'GetGroupsForGroup', 'GetIndex', 'GetLayerByName', 'GetLayerCount', 'GetLayersForGroup', 'GetLayersWithoutGroups', 'InitBaseMap', 'InsertLayer', 'IsStronglyTyped', 'MapLayer', 'MapLayerGroup', 'Metadata', 'MoveDown', 'MoveDownGroup', 'MoveUp', 'MoveUpGroup', 'Name', 'PropertyChanged', 'RemoveAllGroups', 'RemoveAllLayers', 'RemoveBaseMap', 'RemoveGroup', 'RemoveLayer', 'RemoveLayerGroupAndChildLayers', 'ResourceID', 'ResourceType', 'ResourceVersion', 'Serialize', 'SetBottomDrawOrder', 'SetExtents', 'SetExtentsFromFirstAddedLayer', 'SetTopDrawOrder', 'UpdateDynamicGroupName', 'ValidatingSchema', '__doc__', '__repr__']
>>> 

comment:3 by jng, 11 years ago

Resolution: invalid
Status: newclosed

Confirmed that clr.ImportExtensions() will import any extension methods from the given namespace. Nothing to do on my end. Closing.

IronPython 2.7.1 (2.7.0.40) on .NET 4.0.30319.18213
Type "help", "copyright", "credits" or "license" for more information.
>>> conn = app.GetConnection(app.GetConnectionNames()[0])
>>> import clr
>>> clr.AddReference("OSGeo.MapGuide.MaestroAPI")
>>> import OSGeo
>>> mdf = conn.ResourceService.GetResource("Library://Samples/Sheboygan/Maps/Sheboygan.MapDefinition")
>>> layer = mdf.GetLayerByName("Parcels")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'MapDefinition' object has no attribute 'GetLayerByName'
>>> clr.ImportExtensions(OSGeo.MapGuide.ObjectModels.MapDefinition)
>>> layer = mdf.GetLayerByName("Parcels")
>>> layer.Name
'Parcels'
>>> 
Note: See TracTickets for help on using tickets.