You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@chemistry.apache.org by "Jeff Potts (Created) (JIRA)" <ji...@apache.org> on 2011/12/01 18:58:40 UTC

[jira] [Created] (CMIS-481) Cannot set a property to null

Cannot set a property to null
-----------------------------

                 Key: CMIS-481
                 URL: https://issues.apache.org/jira/browse/CMIS-481
             Project: Chemistry
          Issue Type: Bug
          Components: python-cmislib
            Reporter: Jeff Potts
            Assignee: Jeff Potts
            Priority: Minor


Currently, when you create a props dict and use it with either createDocument or updateProperties, the code tries to guess the appropriate cmis element name (cmis:propertyString, cmis:propertyDateTime, etc.) by performing a type test on the value. It does not currently do a lookup to the type definition to determine the property type (or even validate that the property name is defined as part of the property).

Additionally, there is no specific check for None. So if you want to try to set a property to null there is no way to do it. The code will treat properties set to None as a string. If you happen to be setting a string prop, the value will be converted to the string "None". If you happen to be setting any other data type, it is likely you'll see a runtime exception.

>>> doc.properties['sc:level']
4
>>> doc = doc.updateProperties({'sc:level':None})
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/src/chemistry/cmislib/src/cmislib/model.py", line 1947, in updateProperties
    **args)
  File "/opt/src/chemistry/cmislib/src/cmislib/model.py", line 283, in put
    self._processCommonErrors(result)
  File "/opt/src/chemistry/cmislib/src/cmislib/model.py", line 315, in _processCommonErrors
    raise RuntimeException(error.status, error.url)
cmislib.exceptions.RuntimeException: Error 500 at http://localhost:8080/alfresco/s/cmis/s/workspace:SpacesStore/i/4d783751-0a96-4b01-96a1-2b3e03d45d90
>>> doc = doc.updateProperties({'sc:difficulty':None})
>>> doc.properties['sc:difficulty']
u'None'

In order to properly set a property to null, the code cannot rely on the type test. It will have to do a lookup to the type definition so that it can figure out which cmis property element name to use. As long as we're incurring the cost of the type definition lookup, we might as well validate that the property is defined.


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Resolved] (CMIS-481) Cannot set a property to null

Posted by "Jeff Potts (Resolved) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CMIS-481?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jeff Potts resolved CMIS-481.
-----------------------------

    Resolution: Fixed

Fixed and checked in (rev 1210717). Now, when you attempt to set a property and the property value is None, cmislib does a lookup to determine the property data type. Note that at the current time that is the only time the lookup is performed. For all other non-None values, cmislib uses the type check.

Prior to this fix it was impossible to unset a property.
                
> Cannot set a property to null
> -----------------------------
>
>                 Key: CMIS-481
>                 URL: https://issues.apache.org/jira/browse/CMIS-481
>             Project: Chemistry
>          Issue Type: Bug
>          Components: python-cmislib
>            Reporter: Jeff Potts
>            Assignee: Jeff Potts
>            Priority: Minor
>
> Currently, when you create a props dict and use it with either createDocument or updateProperties, the code tries to guess the appropriate cmis element name (cmis:propertyString, cmis:propertyDateTime, etc.) by performing a type test on the value. It does not currently do a lookup to the type definition to determine the property type (or even validate that the property name is defined as part of the property).
> Additionally, there is no specific check for None. So if you want to try to set a property to null there is no way to do it. The code will treat properties set to None as a string. If you happen to be setting a string prop, the value will be converted to the string "None". If you happen to be setting any other data type, it is likely you'll see a runtime exception.
> >>> doc.properties['sc:level']
> 4
> >>> doc = doc.updateProperties({'sc:level':None})
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
>   File "/opt/src/chemistry/cmislib/src/cmislib/model.py", line 1947, in updateProperties
>     **args)
>   File "/opt/src/chemistry/cmislib/src/cmislib/model.py", line 283, in put
>     self._processCommonErrors(result)
>   File "/opt/src/chemistry/cmislib/src/cmislib/model.py", line 315, in _processCommonErrors
>     raise RuntimeException(error.status, error.url)
> cmislib.exceptions.RuntimeException: Error 500 at http://localhost:8080/alfresco/s/cmis/s/workspace:SpacesStore/i/4d783751-0a96-4b01-96a1-2b3e03d45d90
> >>> doc = doc.updateProperties({'sc:difficulty':None})
> >>> doc.properties['sc:difficulty']
> u'None'
> In order to properly set a property to null, the code cannot rely on the type test. It will have to do a lookup to the type definition so that it can figure out which cmis property element name to use. As long as we're incurring the cost of the type definition lookup, we might as well validate that the property is defined.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Closed] (CMIS-481) Cannot set a property to null

Posted by "Jeff Potts (Closed) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CMIS-481?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jeff Potts closed CMIS-481.
---------------------------

    
> Cannot set a property to null
> -----------------------------
>
>                 Key: CMIS-481
>                 URL: https://issues.apache.org/jira/browse/CMIS-481
>             Project: Chemistry
>          Issue Type: Bug
>          Components: python-cmislib
>            Reporter: Jeff Potts
>            Assignee: Jeff Potts
>            Priority: Minor
>
> Currently, when you create a props dict and use it with either createDocument or updateProperties, the code tries to guess the appropriate cmis element name (cmis:propertyString, cmis:propertyDateTime, etc.) by performing a type test on the value. It does not currently do a lookup to the type definition to determine the property type (or even validate that the property name is defined as part of the property).
> Additionally, there is no specific check for None. So if you want to try to set a property to null there is no way to do it. The code will treat properties set to None as a string. If you happen to be setting a string prop, the value will be converted to the string "None". If you happen to be setting any other data type, it is likely you'll see a runtime exception.
> >>> doc.properties['sc:level']
> 4
> >>> doc = doc.updateProperties({'sc:level':None})
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
>   File "/opt/src/chemistry/cmislib/src/cmislib/model.py", line 1947, in updateProperties
>     **args)
>   File "/opt/src/chemistry/cmislib/src/cmislib/model.py", line 283, in put
>     self._processCommonErrors(result)
>   File "/opt/src/chemistry/cmislib/src/cmislib/model.py", line 315, in _processCommonErrors
>     raise RuntimeException(error.status, error.url)
> cmislib.exceptions.RuntimeException: Error 500 at http://localhost:8080/alfresco/s/cmis/s/workspace:SpacesStore/i/4d783751-0a96-4b01-96a1-2b3e03d45d90
> >>> doc = doc.updateProperties({'sc:difficulty':None})
> >>> doc.properties['sc:difficulty']
> u'None'
> In order to properly set a property to null, the code cannot rely on the type test. It will have to do a lookup to the type definition so that it can figure out which cmis property element name to use. As long as we're incurring the cost of the type definition lookup, we might as well validate that the property is defined.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (CMIS-481) Cannot set a property to null

Posted by "Jeff Potts (Updated) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CMIS-481?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jeff Potts updated CMIS-481:
----------------------------

    Affects Version/s: cmislib 0.4
                       cmislib 0.4.1
        Fix Version/s: cmislib 0.5
    
> Cannot set a property to null
> -----------------------------
>
>                 Key: CMIS-481
>                 URL: https://issues.apache.org/jira/browse/CMIS-481
>             Project: Chemistry
>          Issue Type: Bug
>          Components: python-cmislib
>    Affects Versions: cmislib 0.4, cmislib 0.4.1
>            Reporter: Jeff Potts
>            Assignee: Jeff Potts
>            Priority: Minor
>             Fix For: cmislib 0.5
>
>
> Currently, when you create a props dict and use it with either createDocument or updateProperties, the code tries to guess the appropriate cmis element name (cmis:propertyString, cmis:propertyDateTime, etc.) by performing a type test on the value. It does not currently do a lookup to the type definition to determine the property type (or even validate that the property name is defined as part of the property).
> Additionally, there is no specific check for None. So if you want to try to set a property to null there is no way to do it. The code will treat properties set to None as a string. If you happen to be setting a string prop, the value will be converted to the string "None". If you happen to be setting any other data type, it is likely you'll see a runtime exception.
> >>> doc.properties['sc:level']
> 4
> >>> doc = doc.updateProperties({'sc:level':None})
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
>   File "/opt/src/chemistry/cmislib/src/cmislib/model.py", line 1947, in updateProperties
>     **args)
>   File "/opt/src/chemistry/cmislib/src/cmislib/model.py", line 283, in put
>     self._processCommonErrors(result)
>   File "/opt/src/chemistry/cmislib/src/cmislib/model.py", line 315, in _processCommonErrors
>     raise RuntimeException(error.status, error.url)
> cmislib.exceptions.RuntimeException: Error 500 at http://localhost:8080/alfresco/s/cmis/s/workspace:SpacesStore/i/4d783751-0a96-4b01-96a1-2b3e03d45d90
> >>> doc = doc.updateProperties({'sc:difficulty':None})
> >>> doc.properties['sc:difficulty']
> u'None'
> In order to properly set a property to null, the code cannot rely on the type test. It will have to do a lookup to the type definition so that it can figure out which cmis property element name to use. As long as we're incurring the cost of the type definition lookup, we might as well validate that the property is defined.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira