Advertisement
Guest User

Untitled

a guest
Jul 29th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.10 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. from ladon.ladonizer import ladonize
  3. from ladon.types.ladontype import LadonType
  4. from ladon.types.typeconverter import TypeConverter
  5. import syslog
  6.  
  7. class Group(LadonType):
  8. cn = str
  9. name = str
  10. description = str
  11. numbers = [int]
  12.  
  13. class Person(LadonType):
  14. uid = str
  15. name = str
  16. age = int
  17. groups = [Group]
  18.  
  19. class PersonResponse(LadonType):
  20. person = unicode
  21. name = str
  22. height = [float]
  23. groups = [Group]
  24.  
  25. class MyService:
  26. @ladonize(int,str,[Person],str, rtype=PersonResponse,allow_unsafe_conversion=False,encoding='utf-8')
  27. def adduser(self,id,desc,users,is_public='wefwe',**kw):
  28. """Add a < user to the system. æøå
  29. Storage location is created aswell
  30.  
  31. wpofkwpoef
  32. @param id: The user's ID
  33. @param desc:
  34. Some describing text
  35. Some more
  36. @param is_public:
  37. Mark whether the user should be visible to others or not.
  38. Second line of doc.
  39. owkefposdfwe
  40. @rtype: Line1
  41. Returns information about the result of the method
  42. """
  43.  
  44. tc = TypeConverter('utf-8')
  45.  
  46. response = PersonResponse()
  47. response.person = 'jakobsg'
  48. response.name = tc.from_unicode_string(u'Ærgelige Bendt',str)
  49. response.height = [185.3,23,543,625,423]
  50.  
  51. g1 = Group({'cn':u'g1','name':u'Group1','description':u'1 group','numbers':[u'111',u'222',u'333']},tc=tc)
  52. g2 = Group()
  53. response.groups = [g1]#,g2]
  54. #return [1,2,3,4]
  55. return response
  56.  
  57. @ladonize(rtype=str,encoding='UTF-8')
  58. def deluser(self):
  59. pass
  60.  
  61. class MyService2:
  62. @ladonize(int,str,[Group],str, rtype=[str])
  63. def adduser(self,id,desc,users,is_public='wefwe',**kw):
  64. """Add a < user to the system.
  65. Storage location is created aswell
  66.  
  67. wpofkwpoef
  68. @param id: The user's ID
  69. @param desc:
  70. Some describing text
  71. Some more
  72. @param is_public:
  73. Mark whether the user should be visible to others or not.
  74. Second line of doc.
  75. owkefposdfwe
  76. @rtype: Line1
  77. Returns information about the result of the method
  78. """
  79. return ['2']
  80.  
  81. @ladonize(rtype=str)
  82. def deluser(self):
  83. pass
  84.  
  85.  
  86. #from ladon.ladonizer.collection import global_service_collection
  87. #s = global_service_collection().services_by_name("MyService")
  88. #print s[0].method('adduser')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement