From azurit at pobox.sk Sat Oct 1 13:02:31 2011 From: azurit at pobox.sk (azurIt) Date: Sat, 01 Oct 2011 13:02:31 +0200 Subject: [Soap-Python] Stop method processing via method_call event In-Reply-To: <4E85E5B6.4000907@arskom.com.tr> References: <20110930172652.C03ABDBB@pobox.sk>, <4E85E149.5050702@arskom.com.tr>, <20110930173741.0EB6BAA2@pobox.sk> <4E85E5B6.4000907@arskom.com.tr> Message-ID: <20111001130231.2B52DE4B@pobox.sk> Here is the code, if someone is interested in it :) def return_noperm_function(): return {"state": "noperm"} def check_login(ctx): if not function_for_checking_login_and_password(): ctx.descriptor.function = return_noperm_function ctx.in_object = () tests.event_manager.add_listener("method_call", check_login) Don't forget to somehow bypass other events when returning 'noperm' (for example 'method_return_object'). azur ______________________________________________________________ > Od: "Burak Arslan" > Komu: azurIt > D?tum: 30.09.2011 17:52 > Predmet: Re: [Soap-Python] Stop method processing via method_call event > > CC: soap at python.org >On 30.09.2011 18:37, azurIt wrote: >> Because it will return soap fault, i need to return correct soap response. >> >> > >I'd argue strongly that an authentication error is a legitimate use-case >for a fault. But then it's not my really place to say that. > >Anyway, you can set ctx.descriptor.function in the event to whatever you >want. normally it's set to the function decorated by @rpc. > >also set the ctx.in_object to the argument array to the function. look >at ServiceBase.call_wrapper source. > >burak > > > From azurit at pobox.sk Sat Oct 1 13:46:07 2011 From: azurit at pobox.sk (azurIt) Date: Sat, 01 Oct 2011 13:46:07 +0200 Subject: [Soap-Python] Accessing method arguments inside events In-Reply-To: <20110930172410.55E243EC@pobox.sk> References: <20110930172410.55E243EC@pobox.sk> Message-ID: <20111001134607.6E8F1F41@pobox.sk> This can be done by: for i in ctx.in_object: print i azur ______________________________________________________________ > Od: "azurIt" > Komu: > D?tum: 30.09.2011 17:40 > Predmet: [Soap-Python] Accessing method arguments inside events > >Hi, > >how can i access method arguments via MethodContext ? or by any other way. i need to access them inside events for logging purposes. Thank you. > >azur >_______________________________________________ >Soap mailing list >Soap at python.org >http://mail.python.org/mailman/listinfo/soap > From dieter at handshake.de Tue Oct 4 07:25:05 2011 From: dieter at handshake.de (Dieter Maurer) Date: Tue, 4 Oct 2011 07:25:05 +0200 Subject: [Soap-Python] SOAPpy and WSDLs with nested urns... In-Reply-To: References: Message-ID: <20106.39089.603532.672369@localhost.localdomain> li sts wrote at 2011-9-26 12:47 -0400: >I'm trying to use SOAPpy to access a wsdl with a request that must be formed >like so: > > > > > admin > > localhost > > TS_PRIVTYPE_USERTBL > 1003 > > > >I can't seem to find the proper syntax to create this request, most of the >examples that I've been able to find are for things like a single parameter >(a zip code to get a temperature), and I haven't seen anything that >handles nested urns like this... Are you forced to use "SOAPpy" (which I do not know much about)? If not, you may give "suds" a try. It is a very easy to use SOAP client with quite good adherence to the respective standards. If your WSDL calls for XML request documents like the above, "suds" would give you something similar (you would in addition get a SOAP envelope with namespace declarations -- as required by the standards). -- Dieter From stephan.bellegy at gmail.com Mon Oct 10 12:02:04 2011 From: stephan.bellegy at gmail.com (=?ISO-8859-1?Q?St=E9phan_Bellegy?=) Date: Mon, 10 Oct 2011 12:02:04 +0200 Subject: [Soap-Python] Problem with ComplexType and Integer/String arguments Message-ID: Hello I'm new to soaplib and web services (which means possible stupid question ahead ;-) ). I'm having a problem with soaplib. I've the following function provided by a web service : @soap(Integer, Integer, _returns=Integer) def test(self, n1, n2): ? ? return n1 + n2 The corresponding declaration for the datatypes in the generated WSDL file is ? ? ? ? ? ? name="testResponse"> ? ? ? ? When I use some IDE (Visual Studio, PowerBuilder) to generate code from that WSDL file, whatever the IDE, it generates two classes for test and for testResponse, whose attributes are Strings. Does anyone know if I can tweak my Python declaration so that I avoid complexType and obtain real Integer datatype on my client side ? Thanks -- St?phan From burak.arslan at arskom.com.tr Thu Oct 13 13:14:07 2011 From: burak.arslan at arskom.com.tr (Burak Arslan) Date: Thu, 13 Oct 2011 14:14:07 +0300 Subject: [Soap-Python] Problem with ComplexType and Integer/String arguments In-Reply-To: References: Message-ID: <4E96C7FF.3@arskom.com.tr> On 10/10/11 13:02, St?phan Bellegy wrote: > Does anyone know if I can tweak my Python declaration so that I avoid > complexType and obtain real Integer datatype on my client side ? hi, you're looking for non-wrapped variables. rpclib has the interface in place to support that, but it's not tested so i'm pretty sure it doesn't work. i've also looked at soaplib source and don't think soaplib has support for that at all. but then, maybe your client should be able to handle this? I know suds employs some heuristics to detect wrapped vs non-wrapped wsdl documents and acts accordingly. hth, burak From azurit at pobox.sk Sun Oct 16 22:45:58 2011 From: azurit at pobox.sk (azurIt) Date: Sun, 16 Oct 2011 22:45:58 +0200 Subject: [Soap-Python] Getting client's IP address Message-ID: <20111016224558.46C06892@pobox.sk> Hi, i'm trying to get client's IP address with rpclib running under Apache + mod_wsgi but without success. Any hints ? Thnx. azur From burak.arslan at arskom.com.tr Sun Oct 16 23:14:02 2011 From: burak.arslan at arskom.com.tr (Burak Arslan) Date: Mon, 17 Oct 2011 00:14:02 +0300 Subject: [Soap-Python] Getting client's IP address In-Reply-To: <20111016224558.46C06892@pobox.sk> References: <20111016224558.46C06892@pobox.sk> Message-ID: <4E9B491A.3000105@arskom.com.tr> On 10/16/11 23:45, azurIt wrote: > Hi, > > i'm trying to get client's IP address with rpclib running under Apache + mod_wsgi but without success. Any hints ? Thnx. you have the wsgi environment at ctx.transport.req_env. look at: WsgiMethodContext documentation at: http://arskom.github.com/rpclib/reference/server.html https://github.com/arskom/rpclib/blob/master/src/rpclib/server/wsgi.py#L227 best, burak From azurit at pobox.sk Sun Oct 16 23:29:11 2011 From: azurit at pobox.sk (azurIt) Date: Sun, 16 Oct 2011 23:29:11 +0200 Subject: [Soap-Python] Getting client's IP address In-Reply-To: <4E9B491A.3000105@arskom.com.tr> References: <20111016224558.46C06892@pobox.sk> <4E9B491A.3000105@arskom.com.tr> Message-ID: <20111016232911.B273A2D5@pobox.sk> thnx. for others: ctx.transport.req_env.get("REMOTE_ADDR", "unknown") azur ______________________________________________________________ > Od: "Burak Arslan" > Komu: azurIt > D?tum: 16.10.2011 23:14 > Predmet: Re: [Soap-Python] Getting client's IP address > > CC: soap at python.org >On 10/16/11 23:45, azurIt wrote: >> Hi, >> >> i'm trying to get client's IP address with rpclib running under Apache + mod_wsgi but without success. Any hints ? Thnx. > >you have the wsgi environment at ctx.transport.req_env. > >look at: > >WsgiMethodContext documentation at: >http://arskom.github.com/rpclib/reference/server.html >https://github.com/arskom/rpclib/blob/master/src/rpclib/server/wsgi.py#L227 > >best, >burak > From azurit at pobox.sk Mon Oct 17 12:53:35 2011 From: azurit at pobox.sk (azurIt) Date: Mon, 17 Oct 2011 12:53:35 +0200 Subject: [Soap-Python] Full traceback in method_exception_object in rpclib Message-ID: <20111017125335.06178140@pobox.sk> Hi, is it somehow possible to access full traceback inside method_exception_object event of rpclib ? I was only albe to access fault string via 'ctx.out_error'. Thnx. azur From burak.arslan at arskom.com.tr Mon Oct 17 13:17:05 2011 From: burak.arslan at arskom.com.tr (Burak Arslan) Date: Mon, 17 Oct 2011 14:17:05 +0300 Subject: [Soap-Python] Full traceback in method_exception_object in rpclib In-Reply-To: <20111017125335.06178140@pobox.sk> References: <20111017125335.06178140@pobox.sk> Message-ID: <4E9C0EB1.9060905@arskom.com.tr> On 10/17/11 13:53, azurIt wrote: > Hi, > > is it somehow possible to access full traceback inside method_exception_object event of rpclib ? I was only albe to access fault string via 'ctx.out_error'. Thnx. you need to override call_wrapper in either Application or ServiceBase and do your own exception handling there. e.g. class MyException(Fault): pass @classmethod def call_wrapper(cls,ctx): try: ServiceBase.call_wrapper(ctx) except MyException,e: logger.exception(e) raise except Exception,e: raise MyException("Server", "Unknown error") best, burak From burak.arslan at arskom.com.tr Mon Oct 17 13:20:00 2011 From: burak.arslan at arskom.com.tr (Burak Arslan) Date: Mon, 17 Oct 2011 14:20:00 +0300 Subject: [Soap-Python] Full traceback in method_exception_object in rpclib In-Reply-To: <20111017125335.06178140@pobox.sk> References: <20111017125335.06178140@pobox.sk> Message-ID: <4E9C0F60.7000601@arskom.com.tr> On 10/17/11 13:53, azurIt wrote: > Hi, > > is it somehow possible to access full traceback inside method_exception_object event of rpclib ? I was only albe to access fault string via 'ctx.out_error'. Thnx. you need to override call_wrapper in either Application or ServiceBase and do your own exception handling there. e.g. # changed the place of logger.exception where logger = \ # logging.getLogger(__name__) class MyException(Fault): pass @classmethod def call_wrapper(cls,ctx): try: ServiceBase.call_wrapper(ctx) except MyException,e: raise except Exception,e: logger.exception(e) raise MyException("Server", "Unknown error") best, burak _______________________________________________ Soap mailing list Soap at python.org http://mail.python.org/mailman/listinfo/soap From azurit at pobox.sk Mon Oct 17 13:34:28 2011 From: azurit at pobox.sk (azurIt) Date: Mon, 17 Oct 2011 13:34:28 +0200 Subject: [Soap-Python] Full traceback in method_exception_object inrpclib In-Reply-To: <4E9C0EB1.9060905@arskom.com.tr> References: <20111017125335.06178140@pobox.sk> <4E9C0EB1.9060905@arskom.com.tr> Message-ID: <20111017133428.B4D98142@pobox.sk> But i like how exceptions are handled in rpclib i just additionaly want to send an e-mail when something wrong happens + full traceback. Isn't possible with current implementation ? azur ______________________________________________________________ > Od: "Burak Arslan" > Komu: "soap at python.org" > D?tum: 17.10.2011 13:17 > Predmet: Re: [Soap-Python] Full traceback in method_exception_object inrpclib > >On 10/17/11 13:53, azurIt wrote: >> Hi, >> >> is it somehow possible to access full traceback inside method_exception_object event of rpclib ? I was only albe to access fault string via 'ctx.out_error'. Thnx. > >you need to override call_wrapper in either Application or ServiceBase >and do your own exception handling there. > >e.g. > >class MyException(Fault): > pass > >@classmethod >def call_wrapper(cls,ctx): > try: > ServiceBase.call_wrapper(ctx) > except MyException,e: > logger.exception(e) > raise > except Exception,e: > raise MyException("Server", "Unknown error") > >best, >burak > > >_______________________________________________ >Soap mailing list >Soap at python.org >http://mail.python.org/mailman/listinfo/soap > From burak.arslan at arskom.com.tr Mon Oct 17 13:47:45 2011 From: burak.arslan at arskom.com.tr (Burak Arslan) Date: Mon, 17 Oct 2011 14:47:45 +0300 Subject: [Soap-Python] Full traceback in method_exception_object inrpclib In-Reply-To: <20111017133428.B4D98142@pobox.sk> References: <20111017125335.06178140@pobox.sk> <4E9C0EB1.9060905@arskom.com.tr> <20111017133428.B4D98142@pobox.sk> Message-ID: <4E9C15E1.50808@arskom.com.tr> On 10/17/11 14:34, azurIt wrote: > But i like how exceptions are handled in rpclib i just additionaly want to send an e-mail when something wrong happens + full traceback. Isn't possible with current implementation ? that's how i do what you say in my production deployments. i don't think that's difficult to do. see: http://stackoverflow.com/questions/1350671/inner-exception-with-traceback-in-python#1350981 i'm currently swamped by other work, so patches are welcome. best, burak From madhav.bnk at gmail.com Mon Oct 17 14:07:18 2011 From: madhav.bnk at gmail.com (B.Nanda Kishore) Date: Mon, 17 Oct 2011 17:37:18 +0530 Subject: [Soap-Python] Easy way to Customize Date Format for Date Message-ID: Hello Everybody, I have been using soaplib since a few weeks. One thing caught my eye. Its the "Date" and "DateTime" data types. I wanted to have a customized representation/format of the Date object when the xml tree is generated. The default one is YYYY-MM-DD. But what if I wanted to have YYYY/MM/DD or DD-MM-YYYY ? I have tried to look for a way I can do it with the existing soaplib API. Unfortunately I was not able to figure out. Can you please guide me ? If I know the trick, I can implement it and will send a pull-request for your review. Please help. Here is sample code: from lxml import etree from soaplib.core.model.primitive import String, Date from soaplib.core.model.clazz import ClassModel from soaplib.core.util.model_utils import ClassModelConverter from datetime import datetime class FormattedDate(Date): '''This is supposed to used for a customized Date display''' pass class Employee(ClassModel): ** roll = String dob = FormattedDate(nillable=False, min_occurs=1, max_occurs=1, doc='Date of Birth') emp = Employee() emp.roll = '001' emp.dob = datetime.date(datetime.now()) conv = ClassModelConverter(emp) conv.include_parent = False conv.include_ns = True print conv.to_xml() PS: I haven't tried rpclib , but I guess the customizations which I want to achieve for soaplib, might be the same for rpclib also. If not, can you please clarify ? Regards, Nandakishore -------------- next part -------------- An HTML attachment was scrubbed... URL: From burak.arslan at arskom.com.tr Tue Oct 18 14:50:49 2011 From: burak.arslan at arskom.com.tr (Burak Arslan) Date: Tue, 18 Oct 2011 15:50:49 +0300 Subject: [Soap-Python] Easy way to Customize Date Format for Date In-Reply-To: References: Message-ID: <4E9D7629.4050901@arskom.com.tr> On 10/17/11 15:07, B.Nanda Kishore wrote: > > Hello Everybody, > > I have been using soaplib since a few weeks. One thing caught my eye. > Its the "Date" and "DateTime" data types. I wanted to have a > customized representation/format of the Date object when the xml tree > is generated. The default one is YYYY-MM-DD. But what if I wanted to > have YYYY/MM/DD or DD-MM-YYYY ? I have tried to look for a way I can > do it with the existing soaplib API. Unfortunately I was not able to > figure out. Can you please guide me ? If I know the trick, I can > implement it and will send a pull-request for your review. Please help. > Hello Nanda, The current date format in both soaplib and rpclib respects the SOAP standard which in turn respects relavant iso standard on encoding date/time information. So i do not suggest you to alter the way the Date and DateTime objects are serialized. That said, you can have a look at: https://github.com/arskom/rpclib/blob/master/src/rpclib/model/primitive.py#L343 to see how the date object works in rpclib. copy that class, change its name, alter its from_string and to_string methods to your liking and voila, you have your own date class. it's almost the same for soaplib, just a bit more inconsistent. have a look at: https://github.com/soaplib/soaplib/blob/master/src/soaplib/core/model/primitive.py#L196 you should alter to_parent_element and from_string methods in a custom model class that inherits from SimpleType. hope that helps best burak From vsza at vsza.hu Thu Oct 20 14:28:35 2011 From: vsza at vsza.hu (Veres-Szentkiralyi Andras) Date: Thu, 20 Oct 2011 14:28:35 +0200 Subject: [Soap-Python] UsernameToken vs Python Message-ID: <201110201428.36211.vsza@vsza.hu> Hi, I've written a blog post about my tinkering and experience with securing web services using Python. It's available on the following URL, drop me a mail, if you have any questions or comments. http://techblog.vsza.hu/posts/Secure_web_services_with_Python_part_1_-_UserNameToken.html -- Regards, Andr?s Veres-Szentkir?lyi From azurit at pobox.sk Mon Oct 24 15:10:56 2011 From: azurit at pobox.sk (azurIt) Date: Mon, 24 Oct 2011 15:10:56 +0200 Subject: [Soap-Python] Complex types rpclib Message-ID: <20111024151056.F3654081@pobox.sk> Hi, i'm having problems in setting complex type which element name is reserved Python word (getting syntax error): class perms_request(ComplexModel): and = Array(String) or = Array(String) Any ideas how to resolve this ? I simply cannot change element name cos of backward compatibility (it will be really BIG change in our system). Thnx. azur From burak.arslan at arskom.com.tr Mon Oct 24 15:22:17 2011 From: burak.arslan at arskom.com.tr (Burak Arslan) Date: Mon, 24 Oct 2011 16:22:17 +0300 Subject: [Soap-Python] Complex types rpclib In-Reply-To: <20111024151056.F3654081@pobox.sk> References: <20111024151056.F3654081@pobox.sk> Message-ID: <4EA56689.8000502@arskom.com.tr> On 10/24/11 16:10, azurIt wrote: > Hi, > > i'm having problems in setting complex type which element name is reserved Python word (getting syntax error): > > class perms_request(ComplexModel): > and = Array(String) > or = Array(String) > > Any ideas how to resolve this ? I simply cannot change element name cos of backward compatibility (it will be really BIG change in our system). Thnx. > class perms_request(ComplexModel): _type_info = { 'and': Array(String), 'or': Array(String), } does that work? burak From azurit at pobox.sk Mon Oct 24 15:51:07 2011 From: azurit at pobox.sk (azurIt) Date: Mon, 24 Oct 2011 15:51:07 +0200 Subject: [Soap-Python] Complex types rpclib In-Reply-To: <4EA56689.8000502@arskom.com.tr> References: <20111024151056.F3654081@pobox.sk> <4EA56689.8000502@arskom.com.tr> Message-ID: <20111024155107.07E3CE77@pobox.sk> yes, thank you ! azur ______________________________________________________________ > Od: "Burak Arslan" > Komu: azurIt > D?tum: 24.10.2011 15:22 > Predmet: Re: [Soap-Python] Complex types rpclib > > CC: "soap at python.org" >On 10/24/11 16:10, azurIt wrote: >> Hi, >> >> i'm having problems in setting complex type which element name is reserved Python word (getting syntax error): >> >> class perms_request(ComplexModel): >> and = Array(String) >> or = Array(String) >> >> Any ideas how to resolve this ? I simply cannot change element name cos of backward compatibility (it will be really BIG change in our system). Thnx. >> > >class perms_request(ComplexModel): > _type_info = { > 'and': Array(String), > 'or': Array(String), > } > >does that work? > >burak > From stephan.bellegy at gmail.com Tue Oct 25 09:30:34 2011 From: stephan.bellegy at gmail.com (=?ISO-8859-1?Q?St=E9phan_Bellegy?=) Date: Tue, 25 Oct 2011 09:30:34 +0200 Subject: [Soap-Python] Date type rpclib Message-ID: Hi, I'm having problems with a Date value with this context : class UserUpdate(TableModel, DeclarativeBase): __namespace__ = nameSpace __tablename__ = 'user_update' user_id = Column(sqlalchemy.Integer) date = Column(sqlalchemy.Date, nullable=True) heure = Column(sqlalchemy.Time) @rpc(Int(min_occurs=1, max_occurs=1), _returns=Iterable(UserUpdate)) def tpz_getUserUpdate(ctx, user_id): updates = ctx.udc.session.query(UserUpdate).filter(UserUpdate.user_id == user_id).all() return updates I'm using a MySQL database where where those "date" and "heure" column are respectively DATE and TIME types. Thus, when calling the WS method above, I get the following error message : [...] File "C:\Python27\lib\site-packages\rpclib-2.4.4_beta-py2.7.egg\rpclib\model\primitive.py", line 443, in to_string if value.days < 0: AttributeError: 'datetime.time' object has no attribute 'days' Any ideas how I can fix that ? Thanks -- St?phan From burak.arslan at arskom.com.tr Tue Oct 25 11:11:52 2011 From: burak.arslan at arskom.com.tr (Burak Arslan) Date: Tue, 25 Oct 2011 12:11:52 +0300 Subject: [Soap-Python] Date type rpclib In-Reply-To: References: Message-ID: <4EA67D58.5010109@arskom.com.tr> On 10/25/11 10:30, St?phan Bellegy wrote: > Hi, > > I'm having problems with a Date value with this context : > > class UserUpdate(TableModel, DeclarativeBase): > __namespace__ = nameSpace > __tablename__ = 'user_update' > > user_id = Column(sqlalchemy.Integer) > date = Column(sqlalchemy.Date, nullable=True) > heure = Column(sqlalchemy.Time) > > > @rpc(Int(min_occurs=1, max_occurs=1), > _returns=Iterable(UserUpdate)) > def tpz_getUserUpdate(ctx, user_id): > updates = > ctx.udc.session.query(UserUpdate).filter(UserUpdate.user_id == > user_id).all() > return updates > > I'm using a MySQL database where where those "date" and "heure" column > are respectively DATE and TIME types. > > Thus, when calling the WS method above, I get the following error message : > [...] > File "C:\Python27\lib\site-packages\rpclib-2.4.4_beta-py2.7.egg\rpclib\model\primitive.py", > line 443, in to_string > if value.days < 0: > AttributeError: 'datetime.time' object has no attribute 'days' > > Any ideas how I can fix that ? Thanks > ah. please file a bug report, i'll fix that shortly. From azurit at pobox.sk Tue Oct 25 13:15:47 2011 From: azurit at pobox.sk (azurIt) Date: Tue, 25 Oct 2011 13:15:47 +0200 Subject: [Soap-Python] rpclib and non-unicode strings Message-ID: <20111025131547.3918F733@pobox.sk> Hi, i'm having problems when returning non-unicode strings which contains unicode characters (i have strings in utf-8 but they are not python unicode): ValueError: All strings must be XML compatible: Unicode or ASCII, no NULL bytes or control characters Everything works fine when i convert strings to unicode but i cannot do this with all strings, i don't consider nice and clear to convert all strings just before returning them (i have most of them from MySQL returned by module python-mysql). Is there any way how could rpclib convert this for me before lxml parsing ? Everything is in UTF-8 so it shouldn't be a problem. Thank you. azur From burak.arslan at arskom.com.tr Tue Oct 25 17:02:31 2011 From: burak.arslan at arskom.com.tr (Burak Arslan) Date: Tue, 25 Oct 2011 18:02:31 +0300 Subject: [Soap-Python] Date type rpclib In-Reply-To: References: <4EA67D58.5010109@arskom.com.tr> Message-ID: <4EA6CF87.7070308@arskom.com.tr> On 10/25/11 15:25, St??phan Bellegy wrote: > Thanks Burak > Here it is : https://github.com/arskom/rpclib/issues/104 > > By the way, A sqlalchemy.Time generates : > > > Is there a way to force a type="xs:time" ? > I'm sure I've missed something there... don't be so sure ;) rpclib is still beta software. see my comments in the issue tracker. best, burak From esiotrot at gmail.com Tue Oct 25 17:11:33 2011 From: esiotrot at gmail.com (Michael Wood) Date: Tue, 25 Oct 2011 17:11:33 +0200 Subject: [Soap-Python] Date type rpclib In-Reply-To: <4EA6CF87.7070308@arskom.com.tr> References: <4EA67D58.5010109@arskom.com.tr> <4EA6CF87.7070308@arskom.com.tr> Message-ID: On 25 October 2011 17:02, Burak Arslan wrote: > On 10/25/11 15:25, St??phan Bellegy wrote: >> Thanks Burak >> Here it is : https://github.com/arskom/rpclib/issues/104 >> >> By the way, A sqlalchemy.Time generates : >> >> >> Is there a way to force a type="xs:time" ? >> I'm sure I've missed something there... > > don't be so sure ;) rpclib is still beta software. > > see my comments in the issue tracker. heh :) And I thought there must be a good reason there was a Date primitive, but no Time. I suppose I should have asked. -- Michael Wood From burak.arslan at arskom.com.tr Tue Oct 25 19:29:50 2011 From: burak.arslan at arskom.com.tr (Burak Arslan) Date: Tue, 25 Oct 2011 20:29:50 +0300 Subject: [Soap-Python] rpclib and non-unicode strings In-Reply-To: <20111025131547.3918F733@pobox.sk> References: <20111025131547.3918F733@pobox.sk> Message-ID: <4EA6F20E.3070104@arskom.com.tr> On 10/25/11 14:15, azurIt wrote: > Hi, > > i'm having problems when returning non-unicode strings which contains unicode characters (i have strings in utf-8 but they are not python unicode): > > ValueError: All strings must be XML compatible: Unicode or ASCII, no NULL bytes or control characters > > Everything works fine when i convert strings to unicode but i cannot do this with all strings, i don't consider nice and clear to convert all strings just before returning them (i have most of them from MySQL returned by module python-mysql). Is there any way how could rpclib convert this for me before lxml parsing ? Everything is in UTF-8 so it shouldn't be a problem. Thank you. > utf8 is just one way of encoding unicode data, and i don't want to have hard-coded encodings in rpclib. when I had to deal with a similar problem recently, I chose to tweak my db connection (psycopg) to always return unicode data. i now have peace of mind :) i suggest you to do the same. this of course may not suit your needs. there's a hidden _String type in rpclib.model.primitive in my personal fork. does it work for you? you can set its encoding to whatever you want using _String(encoding='whatever'). I can't decide whether it should be left as String or moved to binary module and renamed to Bytes. does that help? burak From burak.arslan at arskom.com.tr Tue Oct 25 19:35:10 2011 From: burak.arslan at arskom.com.tr (Burak Arslan) Date: Tue, 25 Oct 2011 20:35:10 +0300 Subject: [Soap-Python] Fwd: Date type rpclib In-Reply-To: References: <4EA67D58.5010109@arskom.com.tr> <4EA6CF87.7070308@arskom.com.tr> Message-ID: <4EA6F34E.5040902@arskom.com.tr> On 10/25/11 19:03, St?phan Bellegy wrote: > Hello Burak, > > thanks for the dev repo. > I'd like to test it but quite new to Python, I wouldn't like to break > my existing platform. > Is there a way to install 2 different version of the lib and switching > from one to the other ? > Would virtualenv be the solution ? > yes virtualenv would help, i would not suggest that to a newbie. here's what you should do: 1) first clone my rpclib repository somewhere. git clone git://github.com/plq/rpclib.git 2) in your server's main module, right after you import rpclib, add this: print rpclib.__file__ note the shown file path. 3) in your server's main module, add those to top, before importing anything rpclib-related: import sys sys.path.append('/path/to/the/cloned/rpclib/repo/src') # (where rpclib is checked out to: /path/to/the/cloned/rpclib/repo) again, use 'print rpclib.__file__' and note that the file name has changed. you can switch back to the stable(!) rpclib by commenting the sys.path.append line. let me know how this works. best regards, burak From stephan.bellegy at gmail.com Wed Oct 26 11:45:06 2011 From: stephan.bellegy at gmail.com (=?ISO-8859-1?Q?St=E9phan_Bellegy?=) Date: Wed, 26 Oct 2011 11:45:06 +0200 Subject: [Soap-Python] Fwd: Date type rpclib In-Reply-To: <4EA6F34E.5040902@arskom.com.tr> References: <4EA67D58.5010109@arskom.com.tr> <4EA6CF87.7070308@arskom.com.tr> <4EA6F34E.5040902@arskom.com.tr> Message-ID: Hi Burak ! The dev repo you pointed out works fine as far as these sqlalchmy.Date and sqlalchemy.Time are concerned :-) Thanks a lot for the patch ! Do you have some visibility about a release date ? PS: I think I've found another bug, producing an infinite loop. I'm going to file a new issue on github about this. Thanks again -- St?phan From burak.arslan at arskom.com.tr Wed Oct 26 12:51:33 2011 From: burak.arslan at arskom.com.tr (Burak Arslan) Date: Wed, 26 Oct 2011 13:51:33 +0300 Subject: [Soap-Python] Fwd: Date type rpclib In-Reply-To: References: <4EA67D58.5010109@arskom.com.tr> <4EA6CF87.7070308@arskom.com.tr> <4EA6F34E.5040902@arskom.com.tr> Message-ID: <4EA7E635.30307@arskom.com.tr> On 10/26/11 12:45, St?phan Bellegy wrote: > Hi Burak ! > > The dev repo you pointed out works fine as far as these sqlalchmy.Date > and sqlalchemy.Time are concerned :-) > Thanks a lot for the patch ! Do you have some visibility about a release date ? > I'm waiting for the fix to the regression introduced in https://github.com/arskom/rpclib/issues/97 . you can track its progress at https://github.com/arskom/rpclib/issues/106. i plan to wait a bit more -- if the author does not show up, i'll release rpclib withot that patch. > PS: I think I've found another bug, producing an infinite loop. I'm > going to file a new issue on github about this. > sure :) > Thanks again > you're welcome best, burak From azurit at pobox.sk Sat Oct 29 11:19:36 2011 From: azurit at pobox.sk (azurIt) Date: Sat, 29 Oct 2011 11:19:36 +0200 Subject: [Soap-Python] rpclib and non-unicode strings In-Reply-To: <4EA6F20E.3070104@arskom.com.tr> References: <20111025131547.3918F733@pobox.sk> <4EA6F20E.3070104@arskom.com.tr> Message-ID: <20111029111936.42BC3780@pobox.sk> >> i'm having problems when returning non-unicode strings which contains unicode characters (i have strings in utf-8 but they are not python unicode): >> >> ValueError: All strings must be XML compatible: Unicode or ASCII, no NULL bytes or control characters >> >> Everything works fine when i convert strings to unicode but i cannot do this with all strings, i don't consider nice and clear to convert all strings just before returning them (i have most of them from MySQL returned by module python-mysql). Is there any way how could rpclib convert this for me before lxml parsing ? Everything is in UTF-8 so it shouldn't be a problem. Thank you. >> > >utf8 is just one way of encoding unicode data, and i don't want to have >hard-coded encodings in rpclib. when I had to deal with a similar >problem recently, I chose to tweak my db connection (psycopg) to always >return unicode data. i now have peace of mind :) i suggest you to do the >same. I have finally decided to convert _everything_ to unicode in my code and set all modules to return unicode too (in MySQLdb module, this can be set when doing connection via 'use_unicode' argument). thnx. > >this of course may not suit your needs. there's a hidden _String type in >rpclib.model.primitive in my personal fork. does it work for you? you >can set its encoding to whatever you want using >_String(encoding='whatever'). > >I can't decide whether it should be left as String or moved to binary >module and renamed to Bytes. > >does that help? > >burak > >