smc-python icon indicating copy to clipboard operation
smc-python copied to clipboard

Geolocation update

Open fgazelot opened this issue 6 years ago • 2 comments

Hi David,

I have to update or create a Geolocation element in SMC.

Using ipython, I notice that the request update_or_create( with_status=True ) return always updated = True after creation.

This is the example :

In [4]: from smc.elements.other import Geolocation                                                      

In [5]: instance, updated, created = Geolocation.update_or_create( 
   ...:                 with_status=True, name='Geo_Test', latitude='48.86', longitude='2.33')
   ...:  
   ...: print('instance',instance) 
   ...: print('updated',updated) 
   ...: print('created',created)                                                                        
instance Geolocation(name=Geo_Test)
updated False
created True

In [6]: instance, updated, created = Geolocation.update_or_create( 
   ...:                 with_status=True, name='Geo_Test', latitude='48.86', longitude='2.33')
   ...:  
   ...: print('instance',instance) 
   ...: print('updated',updated) 
   ...: print('created',created)                                                                        
instance Geolocation(name=Geo_Test)
updated True
created False

In [7]: instance, updated, created = Geolocation.update_or_create( 
   ...:                 with_status=True, name='Geo_Test', latitude='48.86', longitude='2.33')
   ...:  
   ...: print('instance',instance) 
   ...: print('updated',updated) 
   ...: print('created',created)                                                                        
instance Geolocation(name=Geo_Test)
updated True
created False

I use this version of smc-python :

In [3]:  smc.__version__                                                                                
Out[3]: '0.7.0-b16'

Did I miss a step?

Best regards,

fgazelot avatar Aug 09 '19 14:08 fgazelot

H David,

Do you have some mintues for check my issue ?

Best regards,

fgazelot avatar Oct 15 '19 14:10 fgazelot

If you're attempting to create multiple Geolocations then it looks like the names of each of the Geo_Tests will need to be unique. Otherwise smc_python will look for the existing Geo_Test element and will update it instead of creating a new one.

llarso avatar Nov 01 '19 14:11 llarso