Re: When does controllers/template/view get called?
Hi, On Jan 26, 6:02 am, Skip Montanaro [EMAIL PROTECTED] wrote: I modified controllers/template/view to def view(self, url): raise TypeError, url print sys.stderr, url return render_response(/%s.myt % url) If I visit (for example)http://localhost:5001/nonexistentI don't see anything like a TypeError. Instead, I get this traceback: Works just fine here. May be it's the version of Python interpreter (2.6)? What if you remove raise statement? Max. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~--~~~~--~~--~--~---
Re: When does controllers/template/view get called?
Works just fine here. May be it's the version of Python interpreter (2.6)? What if you remove raise statement? The raise statement was only my last attempt to get something to work. Note also the print and the unprotected call to render_response(). If I define view() as suggested in its docstring: def view(self, url): try: return render_response('/'+url) except myghty.exception.ComponentNotFound: return Response(code=404) I get the same result. In case it's a routing issue here's my config/routing.make_map sans comments: def make_map(global_conf={}, app_conf={}): root_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) mapper = Mapper(directory=os.path.join(root_path, 'controllers')) mapper.connect('error/:action/:id', controller='error') mapper.connect('', controller='hello', action='index') mapper.connect(':controller/:action/:id') mapper.connect('*url', controller='template', action='view') return mapper Skip --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~--~~~~--~~--~--~---
Re: Another XMLHttpRequest question
Many thanks folks! I'll try use this here. Marcus On 26 jan, 03:45, Uwe Feldtmann [EMAIL PROTECTED] wrote: Markm wrote: I am just begining here ... do you mind if I see that your complete (I mean your controller and defs) code? For eg, I did not understand this piece of code: I'm fighting with the same problem and it'll be very useful if I could learn with you!Hi Markus. I see that Bob Ippolito has already explained the function() { ... } definition - thanks Bob. Most of the code I used was only to test out sending data back and forth between the server and the browser withoutusinghtml forms and would be more confusing than it's worth so I'll sum up what I've learned from experimentation and with the patient assistance of others on this list (thank you all). If anything here is incorrect or could be done better then please let us all know. Simple rules I read somewhere:- Use GET if the data you are sending to the server is less than 512 bytes and can be sent on the url. Use the POST method if the data is more than 512 bytes or needs to be more secure. --- Sending from the browserusingGET:- function toServerByGET(url, fct) { xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange = function() { if ( xmlhttp.readyState==4 ) { fct( xmlhttp.responseText ); } }; xmlhttp.open(GET,url); xmlhttp.send(null); }and is called like this urlAndData = /controllerName/methodName/?parm1= + value1 + amp;parm2= + value2; toServer( urlAndData, responseHandler ) --- Sending from the browserusingPOST:- function toServerByPOST( url, data, fct ) { xmlhttp = new XMLHttpRequest(); xmlhttp.open( POST, url, true ); // note setRequestHeader must appear after .open and is used // to encode the data as though it came from a form (thanks Robert) xmlhttp.setRequestHeader( Content-Type, application/x-www-form-urlencoded ); xmlhttp.onreadystatechange = function() { if ( xmlhttp.readyState==4 ) { fct( xmlhttp.responseText ); } } xmlhttp.send( data ); };and is called like this var data = { id: 1, parm1: value1 parm2: value2}toServerByPOST( /controllerName/methodName, data, responseHandler ); --- The method in the controller is the same in both instances:- class ControllerNameController(BaseController): def methodName(self): value1 = request.params['parm1'] value2 = request.params['parm2'] return Response( responseData ) --- Hope this helps in some way. Uwe. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~--~~~~--~~--~--~---
Small query language?
I would like to build a small app akin to a filemaker database, but web-based, of course. One nice feature of filemaker is the ability to search based on pretty much any field (or combination). I know how to do the searches, but I would like to make a simple query language (things like 2..3, 3, =3, widge*, etc.). I have read a bit about tokenizers. Does using a token system make sense, or is there a better or simpler way? Of course, I have to validate these things and then create SQL from them, so any hints from that point of view are also appreciated. Thanks, Sean --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~--~~~~--~~--~--~---
Re: Small query language?
On 1/26/07, Sean Davis [EMAIL PROTECTED] wrote: I would like to build a small app akin to a filemaker database, but web-based, of course. One nice feature of filemaker is the ability to search based on pretty much any field (or combination). I know how to do the searches, but I would like to make a simple query language (things like 2..3, 3, =3, widge*, etc.). I have read a bit about tokenizers. Does using a token system make sense, or is there a better or simpler way? Of course, I have to validate these things and then create SQL from them, so any hints from that point of view are also appreciated. I did something very similar to this recently. I implemented search expressions like food and (cheese or beer) and translated the expressions into SQL. I made use of Yapps2. I've used PLY in the past. I liked both of them. I can send you code if you want. In the distant past, I wrote an article about writing a programming language in Python: http://www.ddj.com/184405580;jsessionid=NZM4QI22OXGR4QSNDLRSKHSCJUNN2JVN?_requestid=578822 Happy Hacking! -jj -- http://jjinux.blogspot.com/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~--~~~~--~~--~--~---
Re: Pagination research
On 1/25/07, Christoph Haas [EMAIL PROTECTED] wrote: Evening... as some of you may have read on IRC I'm trying to use webhelpers' pagination package. That's a pretty frustrating trip that's more a pydoc text adventure than something that saves me more time than re-inventing the wheel. Anyway... I'm using SQLAlchemy and have defined my Table()s in models/__init__.py. To use the pagination I used from webhelpers import pagination in the lib/helpers.py. Then in a controller I'm trying to paginate like this: domains_paginator, domain_set = \ h.pagination.paginate( model.session_context.current.query(model.DnsDomain), page=0, per_page=100 ) set_count = int(domains_paginator.current) total_pages = len(domains_paginator) While this works it looks very ugly to me. To get a paginable query object of my model I have to call model.session_context.current.query(model.DnsDomain). E. So I used the source of webhelpers/pagination/orm.py and found out that I can feed the webhelpers.pagination.paginate() function either - a Table object or - a Query object Since the above query object was ugly I tried to feed the Table object directly: domains_paginator, domain_set = \ h.pagination.paginate( model.powerdns_domains_table, page=0, per_page=100 ) set_count = int(domains_paginator.current) total_pages = len(domains_paginator) This looks a lot cleaner but doesn't work. The traceback I get is: File '/home/chaas/projekte/dnsdhcp/dnsdhcp/controllers/domains.py', line 12 in index domains_paginator, domain_set = h.pagination.paginate(model.powerdns_domains_table, page=0, per_page=100) File '/usr/lib/python2.4/site-packages/WebHelpers-0.2.2-py2.4.egg/webhelpers/pagination/__init__.py', line 48 in paginate item_count = len(collection) File '/usr/lib/python2.4/site-packages/WebHelpers-0.2.2-py2.4.egg/webhelpers/pagination/orm.py', line 56 in __len__ return self.fn([func.count(1)], from_obj=[s]) NameError: global name 'func' is not defined And at least in the webhelpers/pagination/orm.py there is no reference to any 'func' object. Might this be a bug? Relevant part of the orm.py: class SQLAlchemyLazyTable(Partial): def __getitem__(self, key): if not isinstance(key, slice): raise Exception, SQLAlchemyLazy doesn't support getitem without slicing limit = key.stop - key.start offset = key.start fn = self.fn self.fn = fn.select results = self(limit=limit, offset=offset).execute() self.fn = fn return results def __len__(self): s = self.fn.select(*self.args, **self.kw) return self.fn([func.count(1)], from_obj=[s]) # --- bug? Any other attempt to use a 'partial' (whatever that is) leads to the string You shouldn't have this (which is not really a helpful error message). It appears like paginate() should be able to accept an sqlalchemy.Query() object (which in Pylons's context is model.session_context.current.query(model.DnsDomain)) or an sqlalchemy.Table() object (which in Pylon should mean a models.mymapper coming from assign_mapper()). Wow, this email is pretty cryptic already. :) I hope someone has an idea on how to use pagination correctly. Ben implied on IRC that the pagination stuff could use a facelift. Any comments? Should I put this mail into a Trac ticket? Does anyone have a good example on how to use pagination? The documentation at http://pylonshq.com/WebHelpers/module-webhelpers.pagination.html is poor. I'm willing to send in patches or anything. Just teach me how the holy thing works. :) Thanks. It always seems that no matter where I go using whatever Web technology, the pager is both difficult to understand and in need of some loving. Furthermore, writing your own and getting it just right isn't easy either. *sigh* Perhaps you can be the one who studies the source and makes it a thing of beauty ;) Best Regards, -jj -- http://jjinux.blogspot.com/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~--~~~~--~~--~--~---