|
View:
New views
20 Messages
—
Rating Filter:
Alert me
|
| < Prev | 1 - 2 | Next > |
|
|
Using the authCould some post a snippet on how could uses the authentication?
Thanks |
|
|
Re: Using the authSure,
-- from pyamf.gateway.wsgi import WSGIGateway class UserService(object): def getUsers(self): return ['foo', 'bar'] def auth(username, password): if username == 'foo' and password == 'bar': return True return False gw = WSGIGateway() gw.addService(UserService, name='user_service', authenticator=auth) -- Check the source for more info. Cheers, Nick On Sat, November 24, 2007 7:54 pm, akira wrote: > Could some post a snippet on how could uses the authentication? > > > > Thanks > _______________________________________________ > PyAMF dev mailing list - dev@... > http://lists.pyamf.org/mailman/listinfo/dev > > |
|
|
Re: Using the authThanks Nick!
Nick Joyce wrote: > Sure, > > -- > from pyamf.gateway.wsgi import WSGIGateway > > class UserService(object): > def getUsers(self): > return ['foo', 'bar'] > > def auth(username, password): > if username == 'foo' and password == 'bar': > return True > > return False > > gw = WSGIGateway() > > gw.addService(UserService, name='user_service', authenticator=auth) > -- > > Check the source for more info. > > Cheers, > > Nick > > On Sat, November 24, 2007 7:54 pm, akira wrote: > >> Could some post a snippet on how could uses the authentication? >> >> >> >> Thanks >> _______________________________________________ >> PyAMF dev mailing list - dev@... >> http://lists.pyamf.org/mailman/listinfo/dev >> >> >> > > > _______________________________________________ > PyAMF dev mailing list - dev@... > http://lists.pyamf.org/mailman/listinfo/dev > > |
|
|
Broken pipeHi,
After getting the database structure from Arnar, I build a Django project based on the CustomerInfoExampleAPI provided by macromedia/adobe. I can't figure out how to handle the resulting data, an example: AS2 var pc:PendingCall = custService.getCategories(); // get all categories AMF_views.py: def getCategories(): category_list = Category.objects.all() str = "" for c in category_list: str += " | %s" % c.Name return str This is working fine in Flash. Trace outputs a string of categories. AMF_views.py: def getCategories(): category_list = Category.objects.all() return category_list This raises errors Trace: no response from server yet. Error opening URL "http://192.168.1.50:8000/customers/gateway/" Terminal: Django version 0.97-pre-SVN-6718, using settings 'flashboard.settings' Development server is running at http://192.168.1.50:8000/ Quit the server with CONTROL-C. Traceback (most recent call last): File "/usr/local/lib/python2.5/site-packages/django/core/servers/ basehttp.py", line 279, in run self.finish_response() File "/usr/local/lib/python2.5/site-packages/django/core/servers/ basehttp.py", line 318, in finish_response self.write(data) File "/usr/local/lib/python2.5/site-packages/django/core/servers/ basehttp.py", line 402, in write self._write(data) File "/usr/local/lib/python2.5/socket.py", line 262, in write self.flush() File "/usr/local/lib/python2.5/socket.py", line 249, in flush self._sock.sendall(buffer) error: (32, 'Broken pipe') Question: What should I return? Cheers, --Rob |
|
|
Re: Broken pipeOn Nov 26, 2007 5:19 PM, Robert Slotboom <rob.slotboom@...> wrote:
> AMF_views.py: > def getCategories(): > category_list = Category.objects.all() > return category_list This guy will return a list of objects produced by the Django ORM. You either need to make sure PyAMF can convert those objects to AMF (Nick, how is that handled by default?) or ask Django to give you a list of dictionaries instead, like this: def getCategories(): category_list = Category.objects.all().values() return category_list Arnar |
|
|
Re: Broken pipeThat's quick :-)
I'll give it a try later. thanks, Rob Op 26-nov-07 om 18:26 heeft Arnar Birgisson het volgende geschreven: > On Nov 26, 2007 5:19 PM, Robert Slotboom <rob.slotboom@...> > wrote: >> AMF_views.py: >> def getCategories(): >> category_list = Category.objects.all() >> return category_list > > This guy will return a list of objects produced by the Django ORM. You > either need to make sure PyAMF can convert those objects to AMF (Nick, > how is that handled by default?) or ask Django to give you a list of > dictionaries instead, like this: > > def getCategories(): > category_list = Category.objects.all().values() > return category_list > > Arnar > _______________________________________________ > PyAMF dev mailing list - dev@... > http://lists.pyamf.org/mailman/listinfo/dev > |
|
|
Re: Broken pipe
Simple objects should be automatically encoded. I made some changes in a branch (http://pyamf.org/browser/pyamf/branches/gateway-tests-66) that may have already fixed this. Can you post a copy of the sql, and relevant django files so that I can run through it and find out what is what.
Zip's only please! Thanks Nick On Mon, 2007-11-26 at 17:26 +0000, Arnar Birgisson wrote: On Nov 26, 2007 5:19 PM, Robert Slotboom <rob.slotboom@...> wrote: > AMF_views.py: > def getCategories(): > category_list = Category.objects.all() > return category_list This guy will return a list of objects produced by the Django ORM. You either need to make sure PyAMF can convert those objects to AMF (Nick, how is that handled by default?) or ask Django to give you a list of dictionaries instead, like this: def getCategories(): category_list = Category.objects.all().values() return category_list Arnar _______________________________________________ PyAMF dev mailing list - dev@... http://lists.pyamf.org/mailman/listinfo/dev |
|
|
Re: Broken pipeHi Nick,
Op 26-nov-07 om 18:41 heeft Nick Joyce het volgende geschreven: > Simple objects should be automatically encoded. I made some changes > in a branch (http://pyamf.org/browser/pyamf/branches/gateway-tests-66) > that may have already fixed this. Can you post a copy of the sql, and > relevant django files so that I can run through it and find out what > is what. > > Zip's only please! I edited the function according to Arnars advice: def getCategories(): category_list = Category.objects.all().values() return category_list But I get the same kind of error: Traceback (most recent call last): File "/usr/local/lib/python2.5/site-packages/django/core/servers/ basehttp.py", line 279, in run self.finish_response() File "/usr/local/lib/python2.5/site-packages/django/core/servers/ basehttp.py", line 318, in finish_response self.write(data) File "/usr/local/lib/python2.5/site-packages/django/core/servers/ basehttp.py", line 402, in write self._write(data) File "/usr/local/lib/python2.5/socket.py", line 262, in write self.flush() File "/usr/local/lib/python2.5/socket.py", line 249, in flush self._sock.sendall(buffer) error: (32, 'Broken pipe') The attached zip file contains the complete Django project. Below you can find the AS2 script for simple testing: import mx.remoting.Service; // import Service class import mx.rpc.FaultEvent; // import FaultEvent class import mx.remoting.PendingCall // import PendingCall class import mx.rpc.ResultEvent // import ResultEvent class import mx.rpc.RelayResponder // import RelayResponder class mx.remoting.debug.NetDebug.initialize(); var myService:Service = new Service("http://192.168.1.50:8000/customers/ gateway/",null,"customerData", null, null); trace( "no response from server yet." ); // This var holds the data we want to pass to the remote service. var param = "Hello World!"; var pc1:PendingCall = myService.echo(this.param); pc1.responder = new RelayResponder(this, "getData_Result", "getData_Fault"); var pc2:PendingCall = myService.getCategories(); pc2.responder = new RelayResponder(this, "getData_Result", "getData_Fault"); function getData_Result( re:ResultEvent ):Void { // receive result trace( re.result ); } function getData_Fault( fe:FaultEvent ):Void { trace( "There was a problem: " ); for (var prop:String in fe.fault){ trace(prop + " - " + fe.fault[prop]); } } |
|
|
Django's broken pipeHi Nick,
Ceci n’est pas une pipe :-) Have you found some time for looking at the sample code (Django) I posted yesterday? Cheers, Rob |
|
|
Re: Django's broken pipe
Hey Rob,
I have, and am right in the middle of putting together some changes that will allow to handle Django models (and others) with (hopefully!) ease. I'll report back here when I have something concrete to show (should be sometime tomorrow). Hang fire til then! Cheers, Nick On Wed, 2007-11-28 at 17:29 +0100, Robert Slotboom wrote: Hi Nick, Ceci n’est pas une pipe :-) Have you found some time for looking at the sample code (Django) I posted yesterday? Cheers, Rob _______________________________________________ PyAMF dev mailing list - dev@... http://lists.pyamf.org/mailman/listinfo/dev |
|
|
Re: Django's broken pipeHi Nick,
I wish you all the luck that you can get }: o ) Rob Op 28-nov-07 om 17:40 heeft Nick Joyce het volgende geschreven: > Hey Rob, > > I have, and am right in the middle of putting together some changes > that will allow to handle Django models (and others) with (hopefully!) > ease. > > I'll report back here when I have something concrete to show (should > be sometime tomorrow). Hang fire til then! > > Cheers, > > Nick > > On Wed, 2007-11-28 at 17:29 +0100, Robert Slotboom wrote: >> Hi Nick, >> >> Ceci n’est pas une pipe :-) >> >> Have you found some time for looking at the sample code (Django) I >> posted yesterday? >> >> Cheers, >> >> Rob >> >> >> _______________________________________________ >> PyAMF dev mailing list - dev@... >> http://lists.pyamf.org/mailman/listinfo/dev >> > _______________________________________________ > PyAMF dev mailing list - dev@... > http://lists.pyamf.org/mailman/listinfo/dev |
|
|
for Thijs > responder orderHoi Thijs,
Op het web vond ik het volgende voorbeeld. Misschien heb je er iets aan. Met vriendelijke groeten, Robert Slotboom |
|
|
Re: for Thijs > responder orderThanks Robert but I think we will be able to use Python tests to fix
the responder order. You could use this to test that fix though. Thijs On Nov 29, 2007, at 6:43 PM, Robert Slotboom wrote: > Hoi Thijs, > > Op het web vond ik het volgende voorbeeld. Misschien heb je er iets > aan. > > > Met vriendelijke groeten, > > Robert Slotboom > > <qwiRemoting_Demo.zip>_______________________________________________ > PyAMF dev mailing list - dev@... > http://lists.pyamf.org/mailman/listinfo/dev |
|
|
Django CustomerInfoHi All,
I've got a part of the CustomerInfoAPI example running. The combo box is showing the three available category types. After selection I get different objects back. The recordset for categories is working, Django > list(Category.objects.all()) The recordset for customers is collecting objects, but they don't show up in the grid. I'll have a look at that later. Cheers, Rob |
|
|
Remoting Objects > recordsetHi folks,
As some of you know, I'm trying to get an existing macromedia example running towards a Django gateway. The first problems are solved, the next one just arose... I'm trying to get a valid recordset. About this kind of data structure not much can be found. The help files for remoting objects tell this: About record sets A record set is a two-dimensional data table. The rows of the table correspond to individual data records, such as the data for a particular product or employee. The columns of the table correspond to different fields of a record, such as an employee's title or a product color. A RecordSet object represents a record set in Flash. It contains the following elements: • An array of records • The names of the columns • A reference to the application server, if the record set is pageable Typically, service functions return RecordSet objects to your Flash application. However, you can also use ActionScript RecordSet methods to create and manage record sets directly in ActionScript. The ability to create a RecordSet object enables you to create custom client-side data structures for use in Flash UI Components. You access record set rows using the row index, much like in an array. The first record is at index 0, the second record is at index 1, and so on. Record indexes are relative. If you insert a record into a record set, all the indexes of all records in the RecordSet object starting with the index at which you insert the new record get incremented by one. RecordSet object records also have unique IDs that are never changed. If you insert a record in a RecordSet object, it gets a new unique ID and all other record IDs are unchanged. If you delete a record, its ID is deleted and is not reused. Flash Remoting MX uses this ID internally, and you cannot use it to access a record, but you can use the RecordSet.getItemID method to determine the ID for any record. Note: You cannot send RecordSet objects to the application server. Is there further documentation about this anywhere on the web, or has someone an idea about how to create such a structure? Cheers, Rob |
|
|
more on recordsetsHi Arnar, Thijs and Nick,
I found additional information about the structure of a recordset at osflash [1] Can some of you please help me converting this information into a Django/Python object? [1] http://osflash.org/documentation/amf/recordset Toodle dooo, --Rob |
|
|
Re: recordsets > python questionHi again,
Regarding my Django + pyamf + mx.romotingobjects thing, I've found additional information about the recordsetstructure. The code comes from flashticle [1] which is a MIT licensed Python 2.4 library implementing various Macromedia Flash related data formats and protocols. [1] http://osflash.org/flashticle ### flashticle/remoting.py ### [snip] def recordset(colnames, rows, identifier=None): try: count = len(rows) except TypeError: rows = list(rows) count = len(rows) if identifier is None: identifier = 'RecordSet:' + str(getIdentifier()) return typedobject("RecordSet", { 'serverInfo': { 'totalCount': count, 'initialData': rows, 'cursor': 1, 'serviceName': 'PageAbleResult', 'columnNames': colnames, 'version': 1, 'id': identifier, }, }) ### my amf_views.py ### def getIdentifier(ctr=count(1)): return ctr.next() def getCustomers(CategoryID, identifier=None): # return list(CustomerInfo.objects.filter(CategoryID__exact=CategoryID)) colnames = ['ID','CategoryID','Name','Active','Logo','Details','TotalSales'] custList = CustomerInfo.objects.filter(CategoryID__exact=CategoryID) try: count = len(custList) rows = [] for c in custList: row = [ c.ID, c.CategoryID, c.Name, c.Active, c.Logo, c.Details, c.TotalSales] rows.append(row) except TypeError: rows = list(custList) count = len(rows) if identifier is None: identifier = 'RecordSet:' + str(getIdentifier()) return typedobject("RecordSet", { 'serverInfo': { 'totalCount': count, 'initialData': rows, 'cursor': 1, 'serviceName': 'PageAbleResult', 'columnNames': colnames, 'version': 1, 'id': identifier, }, }) ### Result ### Off coarse this doesn't work because I've no typeobject class defined. Looking at the flashticle code, I dont't have any idea how to create one and I don't want to include another library. Can some pythonist tell me how to create the right object to return? Bye, --Rob |
|
|
for Nick > recordsetsHi Nick,
I think I've looked to far [1] because the recordset object is provided in the pyamf source. [1] http://osflash.org/flashticle Given the following code, can you please tell me how to create the recordset object? def getIdentifier(ctr=count(1)): return ctr.next() def getCustomers(CategoryID, identifier=None): # return list(CustomerInfo.objects.filter(CategoryID__exact=CategoryID)) colnames = ['ID','CategoryID','Name','Active','Logo','Details','TotalSales'] custList = CustomerInfo.objects.filter(CategoryID__exact=CategoryID) try: count = len(custList) rows = [] for c in custList: row = [ c.ID, c.CategoryID, c.Name, c.Active, c.Logo, c.Details, c.TotalSales] rows.append(row) except TypeError: rows = list(custList) count = len(rows) if identifier is None: identifier = 'RecordSet:' + str(getIdentifier()) return typedobject("RecordSet", { 'serverInfo': { 'totalCount': count, 'initialData': rows, 'cursor': 1, 'serviceName': 'PageAbleResult', 'columnNames': colnames, 'version': 1, 'id': identifier, }, }) |
|
|
Re: for Nick > recordsetsHey there,
I don't know a lot about this, but from what I've seen, recordsets sent via amf seem to be just identifers for recordsets that live on the server. The client can then call .getRecords() with offset and limits etc. This is a little bit out of scope for an AMF library to implement. It will be implementation specific how the recordsets are stored between requests on the server. For example, a forked apache server running a gateway via mod_python or mod_wsgi, has to somehow serialize data about the recordset as the processes don't share memory. This is something that would be handled differently in that situation as compared with Django, Twisted or a specific WSGI implementation. Nick, have you thought about an API for this? Arnar On Dec 1, 2007 11:19 AM, Robert Slotboom <rob.slotboom@...> wrote: > Hi Nick, > > I think I've looked to far [1] because the recordset object is provided > in the pyamf source. > > [1] http://osflash.org/flashticle > > Given the following code, can you please tell me how to create the > recordset object? > > > def getIdentifier(ctr=count(1)): > return ctr.next() > > def getCustomers(CategoryID, identifier=None): > # return > list(CustomerInfo.objects.filter(CategoryID__exact=CategoryID)) > colnames = > ['ID','CategoryID','Name','Active','Logo','Details','TotalSales'] > custList = CustomerInfo.objects.filter(CategoryID__exact=CategoryID) > try: > count = len(custList) > rows = [] > for c in custList: > row = [ c.ID, c.CategoryID, c.Name, c.Active, c.Logo, > c.Details, c.TotalSales] > rows.append(row) > except TypeError: > rows = list(custList) > count = len(rows) > > if identifier is None: > identifier = 'RecordSet:' + str(getIdentifier()) > > return typedobject("RecordSet", { > 'serverInfo': { > 'totalCount': count, > 'initialData': rows, > 'cursor': 1, > 'serviceName': 'PageAbleResult', > 'columnNames': colnames, > 'version': 1, > 'id': identifier, > }, > }) > _______________________________________________ > PyAMF dev mailing list - dev@... > http://lists.pyamf.org/mailman/listinfo/dev > > |
|
|
Re: more on recordsetsHi Robert,
have you looked at the recordset example in the examples trunk [1]? hth, Thijs [1] http://pyamf.org/browser/examples/trunk/recordset/python/ gateway.py#L12 On Dec 1, 2007, at 8:50 AM, Robert Slotboom wrote: > Hi Arnar, Thijs and Nick, > > I found additional information about the structure of a recordset > at osflash [1] > Can some of you please help me converting this information into a > Django/Python object? > > [1] http://osflash.org/documentation/amf/recordset > > Toodle dooo, > > --Rob > > > _______________________________________________ > PyAMF dev mailing list - dev@... > http://lists.pyamf.org/mailman/listinfo/dev |
| < Prev | 1 - 2 | Next > |
| Free embeddable forum powered by Nabble | Forum Help |