After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 684409 - rename SoupKnownStatusCode
rename SoupKnownStatusCode
Status: RESOLVED FIXED
Product: libsoup
Classification: Core
Component: API
2.39.x
Other Linux
: Normal normal
: ---
Assigned To: libsoup-maint@gnome.bugs
libsoup-maint@gnome.bugs
Depends on:
Blocks:
 
 
Reported: 2012-09-19 23:11 UTC by Ángel Guzmán Maeso (shakaran)
Modified: 2013-07-13 15:10 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Ángel Guzmán Maeso (shakaran) 2012-09-19 23:11:05 UTC
"""
The SOUP_STATUS_OK is not introspectable (see introspectable="0"). Also is defined in
Soup.AddressClass (no very intuituve). Better if it would be Soup.Status.OK

In Soup-2.4.gir you can see a field _libsoup_reserved3 defined:

grep -C 30 SOUP_STATUS_OK /usr/share/gir-1.0/Soup-2.4.gir

      <field name="_libsoup_reserved3" introspectable="0">
        <callback name="_libsoup_reserved3">
--
      <member name="malformed"
              value="8"
              c:identifier="SOUP_STATUS_MALFORMED"
              glib:nick="malformed"/>
      <member name="try_again"
              value="9"
              c:identifier="SOUP_STATUS_TRY_AGAIN"
              glib:nick="try-again"/>
      <member name="too_many_redirects"
              value="10"
              c:identifier="SOUP_STATUS_TOO_MANY_REDIRECTS"
              glib:nick="too-many-redirects"/>
      <member name="tls_failed"
              value="11"
              c:identifier="SOUP_STATUS_TLS_FAILED"
              glib:nick="tls-failed"/>
      <member name="continue"
              value="100"
              c:identifier="SOUP_STATUS_CONTINUE"
              glib:nick="continue"/>
      <member name="switching_protocols"
              value="101"
              c:identifier="SOUP_STATUS_SWITCHING_PROTOCOLS"
              glib:nick="switching-protocols"/>
      <member name="processing"
              value="102"
              c:identifier="SOUP_STATUS_PROCESSING"
              glib:nick="processing"/>
      <member name="ok"
              value="200"
              c:identifier="SOUP_STATUS_OK"
              glib:nick="ok"/>
      <member name="created"
              value="201"
              c:identifier="SOUP_STATUS_CREATED"
              glib:nick="created"/>
      <member name="accepted"
              value="202"
              c:identifier="SOUP_STATUS_ACCEPTED"
              glib:nick="accepted"/>
      <member name="non_authoritative"
              value="203"
              c:identifier="SOUP_STATUS_NON_AUTHORITATIVE"
              glib:nick="non-authoritative"/>
      <member name="no_content"
              value="204"
              c:identifier="SOUP_STATUS_NO_CONTENT"
              glib:nick="no-content"/>
      <member name="reset_content"
              value="205"
              c:identifier="SOUP_STATUS_RESET_CONTENT"
              glib:nick="reset-content"/>
      <member name="partial_content"
              value="206"
              c:identifier="SOUP_STATUS_PARTIAL_CONTENT"
              glib:nick="partial-content"/>
      <member name="multi_status"
              value="207"
              c:identifier="SOUP_STATUS_MULTI_STATUS"
              glib:nick="multi-status"/>

So I can't use predefined constants and I have to 
guess the values (only viewing .gir), assuming that in a future will no change.
"""
from gi.repository import Soup 
from gi.repository import Gio

address = '127.0.0.1'
port = 8082

interface = Soup.Address.new(address, port)

# http://developer.gnome.org/gio/unstable/GCancellable.html
cancellable_request = Gio.Cancellable.new()
status = interface.resolve_sync(cancellable_request) 
 
# http://developer.gnome.org/libsoup/stable/libsoup-2.4-soup-status.html#SOUP-STATUS-IS-SERVER-ERROR:CAPS
# This represent the known HTTP status code values
# See very poor documentation SOUP_STATUS_OK (copy and paste from source code defined vars)       
if status == 200:
    print ('Status is SOUP_STATUS_OK. I assume that 200 value will no change in future?')
    
print (dir(Soup.AddressClass._libsoup_reserved3)) # No useful constants
print (Soup.AddressClass._libsoup_reserved3) # property object, no attributes
print (Soup.AddressClass._libsoup_reserved3.ok) # No instrospectable error


"""
RESULT:

Status is SOUP_STATUS_OK. I assume that 200 value will no change in future?
['__class__', '__delattr__', '__delete__', '__doc__', '__eq__', '__format__', '__ge__', '__get__', '__getattribute__', '__gt__', '__hash__', '__init__', '__le__', '__lt__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__set__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'deleter', 'fdel', 'fget', 'fset', 'getter', 'setter']
<property object at 0xb6aa75f4>
Traceback (most recent call last):
  • File "soup_address_test.py", line 96 in <module>
    print (Soup.AddressClass._libsoup_reserved3.ok) # No instrospectable error
AttributeError: 'property' object has no attribute 'ok'
"""
Comment 1 Dan Winship 2012-09-20 00:59:30 UTC
the name of the enum is "SoupKnownStatusCode", so it's introspected as Soup.KnownStatusCode.OK.

I keep meaning to fix this...
Comment 2 Ángel Guzmán Maeso (shakaran) 2012-09-20 01:53:39 UTC
Ok, it works perfect with Soup.KnownStatusCode.OK. Thanks.
Comment 3 Dan Winship 2013-07-13 15:10:08 UTC
finally did this