Announcing Satchmobile

60 views
Skip to first unread message

Stuart Laughlin

unread,
Nov 8, 2011, 4:30:51 PM11/8/11
to satchmo-d...@googlegroups.com
Hello Everyone --

I have begun work on a django app called satchmobile [1]. It is
essentially a set of web services that expose satchmo data in json
format. At this point it is very nascent and a bit hackish, but not
for long (Lord willing). I am using these services to create some
mobile apps for both android and iOS (i.e. iphone / ipad). The mobile
apps will likely remain closed-source, but I plan to contribute the
web services application back to the community.

Has the idea of satchmo web services been considered / discussed here
before? (The list archives seem to indicate no.) Is there any interest
in having these services included as an app within the satchmo project
itself? Basically I am trying to decide whether to fork/branch satchmo
and develop satchmobile as an app there, or to continue as I have
begun, with the web services in a project completely separate from
(although dependent upon) satchmo.

Any insight / feedback greatly appreciated!

1: https://bitbucket.org/sclaughl/satchmobile


--Stuart

Dierckx, Marc

unread,
Nov 9, 2011, 5:47:53 AM11/9/11
to satchmo-d...@googlegroups.com
Hello,

I have implemented webservices on my shop, based on a snippet from the internet with soaplib (hereunder the skeleton). I also have a mobile version (raw hack) of the shop based on dojo mobile. It however keeps the logic of Satchmo

regards,

marc


import StringIO
import base64
from soaplib.serializers.primitive import Boolean, String
from soaplib.service import DefinitionBase, rpc
from soaplib.wsgi import Application
from django.conf import settings
from settings import PROJECT_DIR


from django.http import HttpResponse


def extract_basic_credentials(request):
"""Extact authorization basic credentials from request"""
username, password = None, None
if 'HTTP_AUTHORIZATION' in request.META:
auth = request.META['HTTP_AUTHORIZATION'].split()
if len(auth) == 2:
if auth[0].lower() == "basic":
username, password = base64.b64decode(auth[1]).split(':')
return username, password

class Http401(Exception):
pass


class Http403(Exception):
pass


class DumbStringIO(StringIO.StringIO):
def read(self, n):
return self.getvalue()

# the class which acts as a wrapper between soaplib WSGI functionality and Django
class DjangoSoapApp(Application):

def authenticate(self, request):
"""Authenticate webservice request."""
ws_username = getattr(settings, 'WS_USERNAME', None)
if ws_username:
ws_password = getattr(settings, 'WS_PASSWORD', None)
username, password = extract_basic_credentials(request)
if username == None:
raise Http401("401 Authentication required.")
if username != ws_username or password != ws_password:
raise Http403("403 You're not authorized to use this webservice!")

def __call__(self, request):
# wrap the soaplib response into a Django response object
#self.authenticate(request)g
django_response = HttpResponse()

def start_response(status, headers):

status, reason = status.split(' ', 1)
django_response.status_code = int(status)
for header, value in headers:
django_response[header] = value

environ = request.META.copy()
environ['CONTENT_LENGTH'] = len(request.raw_post_data)
environ['wsgi.input'] = DumbStringIO(request.raw_post_data)
environ['wsgi.multithread'] = False

response = super(DjangoSoapApp, self).__call__(environ, start_response)
django_response.content = '\n'.join(response)

if django_response.status_code == 405:
return HttpResponse("405 Method not allowed for this webservice.",
'text/plain', status=405)
return django_response


from soaplib_handler import DjangoSoapApp
from soaplib.serializers.primitive import Boolean, String, Integer
from soaplib.serializers.clazz import Array
from soaplib.service import DefinitionBase, rpc
from soaplib.wsgi import Application

from django.utils import simplejson
from django.core import serializers
import logging


log = logging.getLogger()

# the class with actual web methods
class MesserShopService(DefinitionBase):

__tns__ = 'http://localhost:8000/webservice/liferay'

@rpc( String, String, String, _returns=String)
def Product(self,language, products):

---- retrieve the --- models you want

return proposals


my_Liferay = DjangoSoapApp([MesserShopService], MesserShopService.__tns__)

1: https://bitbucket.org/sclaughl/satchmobile


--Stuart

--
You received this message because you are subscribed to the Google Groups "Satchmo developers" group.
To post to this group, send email to satchmo-d...@googlegroups.com.
To unsubscribe from this group, send email to satchmo-develop...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/satchmo-developers?hl=en.


winmail.dat

Stuart

unread,
Nov 14, 2011, 5:15:35 PM11/14/11
to Satchmo developers
Marc, thanks for the feedback and the code!

Regarding the overall issue I was trying to work out, please allow me
to rephrase the question. Would the satchmo devs want to include in
satchmo an app that provides services for mobile apps? For the sake of
this conversation, please assume that the app is of sufficient quality
-- I am not looking for a guarantee or anything. Basically I don't
want to waste my time integrating directly with Satchmo if there is no
interest in ever bringing it into the trunk. In that case I would keep
my app its own separate repository, rather than in a forked satchmo
repo, and manage the system boundary differently.

I hope what I am asking makes sense. Some feedback from the main devs
(Chris? Hynek?) would be greatly appreciated.


Thanks!

--Stuart

On Nov 9, 4:47 am, "Dierckx, Marc" <Marc.Dier...@messergroup.com>
wrote:
>  winmail.dat
> 6KViewDownload

Chris Moffitt

unread,
Nov 14, 2011, 9:40:57 PM11/14/11
to satchmo-d...@googlegroups.com
Stuart,

The answer is yes, I would be interested but the biggest challenge is maintaining it going forward. I personally haven't done a lot of mobile development so I'm not sure what it will take to maintain.

I guess what I'm saying is that I want to make sure there's broad interest and willingness to support. Assuming those two conditions are met, then, yes I would be interested in incorporating.

-Chris

hynekcer

unread,
Nov 15, 2011, 12:33:58 PM11/15/11
to Satchmo developers
Stuart, you are one of the most regular helpful contributors in this
discussion for long time. I believe your expierience. It looks app
does not require changes in the core.

Personally, it is a fun I am called one of the main developers of an
ecommerce application and I am asked for mobile devices. I have a bank
account one month, I use some cheapest phone and tomorrow I am going
for a card which will be accepted only in the nearest cash machine.
So, I can test Apache, Cherokee and other Indians :-) easier than a
simple payment method.

A question about integrating depends on how it is implemented. I
communicated sometimes with a newcomer contributor and finally more
work would require to solve consequences than the implementation of a
new functionality itself, I was left alone and came urgent issues.
With you it's vice versa.

I could help with integrating by some script similar to hg rebase so
that your repository could be finally based on Satchmo and merged to
it. It would only change commit IDs and add a prefix satchmo/apps/
satchmo_ext/ before satchmobile/. Your name, date, comments etc. would
remain.

I can promise by a maximum more a help with an unexpected problem with/
after integrating.

Does your app work if you try to move its repository to satchmo/apps/
satchmo_ext/? OK.

I do not know at all, how to try it. Does it work with an Android
Emulator or IOS Emulator on laptop/desktop? Can you write some docs
text?
Your app would be closed source. Can you write a simple unuseful test
app to be possible to verify that services work?

-- Hynek

Stuart Laughlin

unread,
Nov 16, 2011, 4:25:34 PM11/16/11
to satchmo-d...@googlegroups.com
Thanks for the reply, Hynek!

I like your idea about having this application under satchmo_ext.
Frankly I don't know why I didn't think of that myself! In light of
that idea and Chris's reply, my current plan is to fork satchmo on
bitbucket and develop satchmobile as an app under satchmo_ext. That
way, when I make sufficient progress, I can simply submit a pull
request and go through the normal approval process to be included in
the main satchmo repository.

You also raise some good questions about testing. I need to do some
thinking about the best way to do this -- I feel it's a bit odd since
they are services without a client (or with various unknown clients,
you might say).

In terms of trying out the mobile apps, my colleague and I are still
discussing how to best do that. We very well may do something as you
suggested, e.g. freely distribute a mobile app that only has the
ability to browse the product catalog but lacks the ability to add to
cart, wishlist, etc. In the meantime, we have placed some information
(including screenshots) on my colleague's site [1,2]. The 'real' site
is forthcoming.

1: http://johnheerman.com/portfolio/
2: http://johnheerman.com/portfolio/kessel/

Thanks again for the feedback; it's always welcome!


--Stuart

Reply all
Reply to author
Forward
0 new messages