|
List Info
Thread: CP with wxpython for webservices app?
|
|
| CP with wxpython for webservices app? |
  Canada |
2007-06-18 01:41:32 |
Hi CP folks. I'm coming to CP through turbogears, and I am
currently
exploring how best to do a small time booking system for a
client. I
hope to make part of it a turbogears web app, and part of it
( the main
in office part ) use a wxpython front end. The main issues
are that:
- the bookings db MUST stay available even if the stores
connection goes
down, which unfortunately happens sometimes
- the app should normally be usable from multiple locations
- the main server really shouldn't be in the store, which is
a very
technology hostile environment ( dirty 'ol industrial kind
of thing )
So, I was thinking some form of web services based protocal
might make
sense but this is all new to me. If any one has suggestions
or pointers
or words of warning as to whether and how I might use CP in
this regard,
I'd love to hear them. I ordered the new CP book and the
O'Reilly web
services book but they just arrived!
Thanks
Iain
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-users googlegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribe googlegroups.com
For more options, visit this group at h
ttp://groups.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---
|
|
| Re: CP with wxpython for webservices
app? |
  United Kingdom |
2007-06-18 01:51:15 |
Teling you which technology to use is rather hard given the
information
you provide. The CP book introduces REST and the AtomPP
without going
too much into the details but I've heard greta things about
the O'Reilly
book you ordered.
Any protocol based on HTTP is certainly a good idea in the
environment
you describe since the protocol is really resilient to
faults.
- Sylvain
iain duncan a écrit :
> Hi CP folks. I'm coming to CP through turbogears, and I
am currently
> exploring how best to do a small time booking system
for a client. I
> hope to make part of it a turbogears web app, and part
of it ( the main
> in office part ) use a wxpython front end. The main
issues are that:
>
> - the bookings db MUST stay available even if the
stores connection goes
> down, which unfortunately happens sometimes
> - the app should normally be usable from multiple
locations
> - the main server really shouldn't be in the store,
which is a very
> technology hostile environment ( dirty 'ol industrial
kind of thing )
>
> So, I was thinking some form of web services based
protocal might make
> sense but this is all new to me. If any one has
suggestions or pointers
> or words of warning as to whether and how I might use
CP in this regard,
> I'd love to hear them. I ordered the new CP book and
the O'Reilly web
> services book but they just arrived!
>
> Thanks
> Iain
>
>
> >
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-users googlegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribe googlegroups.com
For more options, visit this group at h
ttp://groups.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---
|
|
| Re: CP with wxpython for webservices
app? |
  Canada |
2007-06-18 02:20:06 |
On Mon, 2007-18-06 at 07:51 +0100, Sylvain Hellegouarch
wrote:
> Teling you which technology to use is rather hard given
the information
> you provide. The CP book introduces REST and the AtomPP
without going
> too much into the details but I've heard greta things
about the O'Reilly
> book you ordered.
Thanks for the reply Sylvain. Could you tell me what sort of
information
would be good to provide or to use to help pick
technologies?
Thanks
Iain
>
> Any protocol based on HTTP is certainly a good idea in
the environment
> you describe since the protocol is really resilient to
faults.
>
> - Sylvain
>
> iain duncan a �crit :
> > Hi CP folks. I'm coming to CP through turbogears,
and I am currently
> > exploring how best to do a small time booking
system for a client. I
> > hope to make part of it a turbogears web app, and
part of it ( the main
> > in office part ) use a wxpython front end. The
main issues are that:
> >
> > - the bookings db MUST stay available even if the
stores connection goes
> > down, which unfortunately happens sometimes
> > - the app should normally be usable from multiple
locations
> > - the main server really shouldn't be in the
store, which is a very
> > technology hostile environment ( dirty 'ol
industrial kind of thing )
> >
> > So, I was thinking some form of web services based
protocal might make
> > sense but this is all new to me. If any one has
suggestions or pointers
> > or words of warning as to whether and how I might
use CP in this regard,
> > I'd love to hear them. I ordered the new CP book
and the O'Reilly web
> > services book but they just arrived!
> >
> > Thanks
> > Iain
> >
> >
> > >
>
>
> >
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-users googlegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribe googlegroups.com
For more options, visit this group at h
ttp://groups.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---
|
|
| Re: CP with wxpython for webservices
app? |
  United Kingdom |
2007-06-18 03:17:02 |
iain duncan a écrit :
> On Mon, 2007-18-06 at 07:51 +0100, Sylvain Hellegouarch
wrote:
>
>> Teling you which technology to use is rather hard
given the information
>> you provide. The CP book introduces REST and the
AtomPP without going
>> too much into the details but I've heard greta
things about the O'Reilly
>> book you ordered.
>>
> ng
> Thanks for the reply Sylvain. Could you tell me what
sort of information
> would be good to provide or to use to help pick
technologies?
>
>
Well not really (that sounds bad I know). The thing is that
there aren't
so many standardized technologies out there that add a value
on their
own to build a web service (I can think of the WS-* stack,
AtomPP, the
new Web3S and maybe WebDAV if you want to consider it that
way) but for
the rest it usually comes down to apply the REST principles
to a more or
less strict way.
Technically speaking you will have to understand whether or
not you are
looking at driving your application via a web service and
therefore
exposing a true and well thought API (that will be
implemented atop
HTTP). In that case you ought to consider your service as
something
distinct from a true application on its own, ie a web
application not a
website (which would be made of HTML for example).
The point of a web service is to expose an API. If in your
mind you can
think of such an API for your context, then the O'Reilly
book could
certainly help you deciding the details.
The application the CP books goes through try to show that
your web
application can actually use a web service to be managed
while having a
more static aspect (simple HTML pages) as the view of the
content. The
goal was to say you can expose a simple API that will allow
any
third-party product to manage the application (perform the
basic CRUD
operations for example) therefore make your application much
richer than
if you had written a regular administration panel all in
HTML.
Whether you chose XML or JSON for instance as the message
format doesn't
matter in the end, what matters is designing the API well
enough to
allow the web application to live outside the traditionnal
browser
environment if needed.
- Sylvain
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-users googlegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribe googlegroups.com
For more options, visit this group at h
ttp://groups.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---
|
|
| Re: CP with wxpython for webservices
app? |

|
2007-06-18 03:34:37 |
Hi all
On 6/18/07, Sylvain Hellegouarch <sh defuze.org> wrote:
> Whether you chose XML or JSON for instance as the
message format doesn't
> matter in the end, what matters is designing the API
well enough to
> allow the web application to live outside the
traditionnal browser
> environment if needed.
I use json webservices quite a bit for communication between
various
applications (mostly webapps). I have a few bits of code
that make
life easier:
First of all, Bob Ippolito's simplejson and TurboGears'
jsonify.py. I
then add this to jsonify.py to make it a CherryPy tool:
http://tools.cher
rypy.org/wiki/JSON
My controllers look like this:
class JobInfo:
_cp_config = {'tools.jsonify.on': True}
def tester(self, arg1):
return dict(arg=arg1, doubled=int(arg1)*2)
There's no expose since I use Routes, like this:
def setup_routes():
global dispatcher
d = dispatcher = cherrypy.dispatch.RoutesDispatcher()
d.connect('main', '', controller=Main())
d.connect('jsgen', 'js/:ctrl',
controller=JSGenerator())
d.connect('jobinfo', 'jobinfo/:action',
controller=JobInfo())
return d
def start(config):
cherrypy.config.update(config)
conf = {
'/': {
'request.dispatch': setup_routes(),
'wsgi.pipeline': [('EvalException',
EvalException)],
'request.throw_errors': True,
'tools.encode.on': True,
'tools.encode.encoding': 'UTF-8'
},
}
cherrypy.quickstart(None, config=conf)
JSGenerator is a class that generates a .js interface to
the
webservice, allowing me to call the methods directly from
javascript,
just like "webservices.jobinfo.tester(123)" - I
can post that if
anyone is intersted.
Last but not least, I have this class included wherever I
need to
access the webservice:
import urllib, simplejson
class JsonProxy:
def __init__(self, baseurl):
if baseurl.endswith('/'):
baseurl = baseurl[:-1]
self.baseurl = baseurl
def __getattr__(self, name):
def methodproxy(**kwargs):
url = self.baseurl + '/' + name
for key in kwargs:
if type(kwargs[key]) is unicode:
kwargs[key] =
kwargs[key].encode("utf8")
query = urllib.urlencode(kwargs)
if len(url) + len(query) > 254:
# do post
f = urllib.urlopen(url, query)
else:
f = urllib.urlopen(url + '?' + query)
data = f.read()
f.close()
data = simplejson.loads(data)
return data
return methodproxy
The usage would be something like this:
>>> ws = JsonProxy("http://w
ebservices.example.com/jobinfo")
>>> result = ws.tester(123)
{arg=123, doubled=246}
Arnar
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-users googlegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribe googlegroups.com
For more options, visit this group at h
ttp://groups.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---
|
|
| Re: CP with wxpython for webservices
app? |
  United Kingdom |
2007-06-18 03:38:01 |
As an implementation of a service, this looks very nice I
must say. -
Sylvain
Arnar Birgisson a écrit :
> Hi all
>
> On 6/18/07, Sylvain Hellegouarch <sh defuze.org> wrote:
>
>> Whether you chose XML or JSON for instance as the
message format doesn't
>> matter in the end, what matters is designing the
API well enough to
>> allow the web application to live outside the
traditionnal browser
>> environment if needed.
>>
>
> I use json webservices quite a bit for communication
between various
> applications (mostly webapps). I have a few bits of
code that make
> life easier:
>
> First of all, Bob Ippolito's simplejson and TurboGears'
jsonify.py. I
> then add this to jsonify.py to make it a CherryPy
tool:
> http://tools.cher
rypy.org/wiki/JSON
>
> My controllers look like this:
>
> class JobInfo:
>
> _cp_config = {'tools.jsonify.on': True}
>
> def tester(self, arg1):
> return dict(arg=arg1, doubled=int(arg1)*2)
>
> There's no expose since I use Routes, like this:
>
> def setup_routes():
> global dispatcher
> d = dispatcher =
cherrypy.dispatch.RoutesDispatcher()
> d.connect('main', '', controller=Main())
> d.connect('jsgen', 'js/:ctrl',
controller=JSGenerator())
> d.connect('jobinfo', 'jobinfo/:action',
controller=JobInfo())
> return d
>
>
> def start(config):
> cherrypy.config.update(config)
> conf = {
> '/': {
> 'request.dispatch': setup_routes(),
> 'wsgi.pipeline': [('EvalException',
EvalException)],
> 'request.throw_errors': True,
> 'tools.encode.on': True,
> 'tools.encode.encoding': 'UTF-8'
> },
> }
> cherrypy.quickstart(None, config=conf)
>
>
> JSGenerator is a class that generates a .js interface
to the
> webservice, allowing me to call the methods directly
from javascript,
> just like "webservices.jobinfo.tester(123)" -
I can post that if
> anyone is intersted.
>
>
> Last but not least, I have this class included wherever
I need to
> access the webservice:
>
> import urllib, simplejson
>
> class JsonProxy:
>
> def __init__(self, baseurl):
> if baseurl.endswith('/'):
> baseurl = baseurl[:-1]
> self.baseurl = baseurl
>
> def __getattr__(self, name):
> def methodproxy(**kwargs):
> url = self.baseurl + '/' + name
> for key in kwargs:
> if type(kwargs[key]) is unicode:
> kwargs[key] =
kwargs[key].encode("utf8")
> query = urllib.urlencode(kwargs)
> if len(url) + len(query) > 254:
> # do post
> f = urllib.urlopen(url, query)
> else:
> f = urllib.urlopen(url + '?' + query)
> data = f.read()
> f.close()
> data = simplejson.loads(data)
> return data
> return methodproxy
>
>
> The usage would be something like this:
>
>
>>>> ws = JsonProxy("http://w
ebservices.example.com/jobinfo")
>>>> result = ws.tester(123)
>>>>
> {arg=123, doubled=246}
>
>
> Arnar
>
> >
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-users googlegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribe googlegroups.com
For more options, visit this group at h
ttp://groups.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---
|
|
| Re: CP with wxpython for webservices
app? |

|
2007-06-18 04:00:02 |
On 6/18/07, Sylvain Hellegouarch <sh defuze.org> wrote:
>
> As an implementation of a service, this looks very nice
I must say. -
> Sylvain
Thank you. I think I made my goal, which was to:
1. make it super-easy to add new methods without having to
worry about
that it was to be a web-method (*)
2. make it super-easy to use the service from other python
apps.
The JsonProxy class could also be easily ported to other
languages as
it is simple. You won't get the nice call-like syntax though
in lesser
languages
Arnar
(*) actually I can write a controller in any project,
advertise it
with a specific entry-point (a la setuptools) in setup.py.
Then I
install the egg where my webservices server is running and
it gets
automatically added. I.e. the real setup_routes function
looks like
this:
def setup_routes():
global dispatcher
d = dispatcher = cherrypy.dispatch.RoutesDispatcher()
d.connect('main', '', controller=Main())
d.connect('jsgen', 'js/:ctrl',
controller=JSGenerator())
for plugin in
iter_entry_points("kvosws.controllers"):
d.connect(plugin.name, '%s/:action' % plugin.name,
controller=plugin.load()())
return d
> Arnar Birgisson a écrit :
> > Hi all
> >
> > On 6/18/07, Sylvain Hellegouarch <sh defuze.org> wrote:
> >
> >> Whether you chose XML or JSON for instance as
the message format doesn't
> >> matter in the end, what matters is designing
the API well enough to
> >> allow the web application to live outside the
traditionnal browser
> >> environment if needed.
> >>
> >
> > I use json webservices quite a bit for
communication between various
> > applications (mostly webapps). I have a few bits
of code that make
> > life easier:
> >
> > First of all, Bob Ippolito's simplejson and
TurboGears' jsonify.py. I
> > then add this to jsonify.py to make it a CherryPy
tool:
> > http://tools.cher
rypy.org/wiki/JSON
> >
> > My controllers look like this:
> >
> > class JobInfo:
> >
> > _cp_config = {'tools.jsonify.on': True}
> >
> > def tester(self, arg1):
> > return dict(arg=arg1,
doubled=int(arg1)*2)
> >
> > There's no expose since I use Routes, like this:
> >
> > def setup_routes():
> > global dispatcher
> > d = dispatcher =
cherrypy.dispatch.RoutesDispatcher()
> > d.connect('main', '', controller=Main())
> > d.connect('jsgen', 'js/:ctrl',
controller=JSGenerator())
> > d.connect('jobinfo', 'jobinfo/:action',
controller=JobInfo())
> > return d
> >
> >
> > def start(config):
> > cherrypy.config.update(config)
> > conf = {
> > '/': {
> > 'request.dispatch': setup_routes(),
> > 'wsgi.pipeline': [('EvalException',
EvalException)],
> > 'request.throw_errors': True,
> > 'tools.encode.on': True,
> > 'tools.encode.encoding': 'UTF-8'
> > },
> > }
> > cherrypy.quickstart(None, config=conf)
> >
> >
> > JSGenerator is a class that generates a .js
interface to the
> > webservice, allowing me to call the methods
directly from javascript,
> > just like
"webservices.jobinfo.tester(123)" - I can post
that if
> > anyone is intersted.
> >
> >
> > Last but not least, I have this class included
wherever I need to
> > access the webservice:
> >
> > import urllib, simplejson
> >
> > class JsonProxy:
> >
> > def __init__(self, baseurl):
> > if baseurl.endswith('/'):
> > baseurl = baseurl[:-1]
> > self.baseurl = baseurl
> >
> > def __getattr__(self, name):
> > def methodproxy(**kwargs):
> > url = self.baseurl + '/' + name
> > for key in kwargs:
> > if type(kwargs[key]) is unicode:
> > kwargs[key] =
kwargs[key].encode("utf8")
> > query = urllib.urlencode(kwargs)
> > if len(url) + len(query) > 254:
> > # do post
> > f = urllib.urlopen(url, query)
> > else:
> > f = urllib.urlopen(url + '?' +
query)
> > data = f.read()
> > f.close()
> > data = simplejson.loads(data)
> > return data
> > return methodproxy
> >
> >
> > The usage would be something like this:
> >
> >
> >>>> ws = JsonProxy("http://w
ebservices.example.com/jobinfo")
> >>>> result = ws.tester(123)
> >>>>
> > {arg=123, doubled=246}
> >
> >
> > Arnar
> >
> > >
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-users googlegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribe googlegroups.com
For more options, visit this group at h
ttp://groups.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---
|
|
[1-7]
|
|