Re: [web2py] request.vars convenience

2010-04-15 Thread Mladen Milankovic
On Thursday, April 15, 2010 11:23:15 selecta wrote: > for request.args I can do > > request.args(0) > > and will return None if there is no such element, much nicer than > > request.args[0] if len(request.args)>0 else None > > I always wondered why this does not work for request.vars I have the

[web2py:34935] Re: Creating Models the Web2Py way

2009-11-09 Thread Mladen Milankovic
a little more as I am > still learning MVC and Web2Py. In my PHP app multiple descriptions > gave me the ability to host different formats of content for a single > product. I could do plaintext and html descriptions for use in two > different places. > > On Nov 9, 7:29 am, M

[web2py:34932] Re: Creating Models the Web2Py way

2009-11-09 Thread Mladen Milankovic
n/sql.py", line 1454, in > _create_references > raise SyntaxError, 'Table: table \'%s\'does not exist' % > referenced > SyntaxError: Table: table 'product_description'does not exist > > = > > On Nov 9, 6:55 am, Mladen Milankov

[web2py:34930] Re: Creating Models the Web2Py way

2009-11-09 Thread Mladen Milankovic
Hi. When using reference you don't need the db. part. Only the name of the table. Like: Field('description', 'reference product_description'), It uses the same database as the table you are just creating. regards mmlado On Monday 09 November 2009 13:51:05 David wrote: > So I have the followin

[web2py:34268] Bug with _extra row in version 1.71.0

2009-10-31 Thread Mladen Milankovic
Hi. I updated today to version 1.71.0, and there was a problem with the _extra row. When there are multiple fields that go into to _extra row, only one of them is present. For example when getting separate sums for two fields only the last one can be found in _extra. I debuged a little and found

[web2py:34026] Re: A html helpers "title" attribute

2009-10-29 Thread Mladen Milankovic
Hi. Your missing a comma before the _title attribute. regards mmlado On Thursday 29 October 2009 11:26:01 Doxaliber wrote: > response.write(A(row.autori.nome_autore.title(), _href=URL(r=request, > f="autore", args=row.autori.id) _title="visualizza autori")) > > ^ > SyntaxError: invalid syntax

[web2py:33393] Re: OPTION selected problem

2009-10-21 Thread Mladen Milankovic
Hi. Try: num = 1 SELECT(OPTION('candy',_value=1),OPTION('chocolate',_value=2), value=num) The SELECT will give selected to the option which has the value of num. regards mmlado On Thursday 22 October 2009 05:26:32 Avik Basu wrote: > Sorry, my example was too simplistic for what I am trying to

[web2py:31781] Re: dynamic or queries...

2009-09-28 Thread Mladen Milankovic
Hi. You could try: solution = db(db.solution.id.belongs((request.args[0], request.args[1], request.args[2], request.args[3], etc...))).select() belongs translates to IN in sql. It accepts a list of parameters to which the field will be compared. regards mmlado On Monday 28 September 2009 11:

[web2py:31630] Re: Serving different applications on shared hosting

2009-09-24 Thread Mladen Milankovic
Hi. I think it's a bug in rewrite.py modul. If you open the file, it's in gluon directory, on line 54 you can see the following: if k.find(':/') > 0: i = k.find(':/') k = r'%s:https?://[^:/]+:[a-z]+ %s' % (k[:i], k[i+1:]) Think this should insert regex part for the domain when written

[web2py:31595] Re: executesql

2009-09-24 Thread Mladen Milankovic
Hi. executesql will return results in "natural" form, as the library gives it. Don't know for others, but mysql (try for others), will return a list of tuples of results. In your case: person.ip_user is person[0] person.strafb1 is person[1] try this: {{for person in results:}} {{=person[0]

[web2py:29647] Re: Horizontal menu

2009-08-30 Thread Mladen Milankovic
Hi. I tried it and it didn't work, and then looked at it with firebug and changed it a little. The ul that contains the menu has the class menu, in this case. As you wrote the css, it says ul which is somewhere in some element with class menu. So I changed the definitions like this: ul.menu{

[web2py:29645] Re: Horizontal menu

2009-08-30 Thread Mladen Milankovic
Hi. Don't know how does your code for the menu look like, but I'll assume you're using the built-in function MENU. So if you have something like this: {{=MENU(response.menu, _class = 'web2py-menu web2py-menu-vertical')}} just change the vertical to horizontal, like: {{=MENU(response.menu, _c

[web2py:29644] Re: how to open a file from default.py

2009-08-30 Thread Mladen Milankovic
Hi. Hmm... I thought designers know javascript. At least for design things like this... :) Try something like this. Give a class to the element that needs the click action. You can reference elements in a jquery through any valid css selection. This way you can get all the elements and assig

[web2py:29640] Re: how to open a file from default.py

2009-08-30 Thread Mladen Milankovic
Hi. 1. If you want to open a file you have to give the file with path on the file system and not through url. I do like this: import os filename = os.path.join(request.folder, 'modules', 'appsettings.py') request.folder contains the path to the current application 2. I think it's bad idea to

[web2py:29129] Re: Help query

2009-08-22 Thread Mladen Milankovic
Hi. When you use multiple tables in a query, it return DALStorage object in DALStorage object for each table you requested. Simpler every row object is a dict which contains dict object for each table. try: {{for review in reviews:}} {{=review.reviews.headline}}: {{=review.users.username}}

[web2py:28090] Re: How to a static file as logo

2009-08-06 Thread Mladen Milankovic
Hi. Try: {{=IMG(_src=URL(r=request, c='static', f='Tux.jpg'))}} Everything you want to write out in the view, from python code needs = like: {{=variable}} regards mmlado On Thursday 06 August 2009 16:36:11 Johann Spies wrote: > I am trying my first web2py page and I am wasting hours even afte

[web2py:28085] Re: get the row id from form

2009-08-06 Thread Mladen Milankovic
Hi. The id of inserted records will be in form.vars.id, assuming you call the form, form. Like: if form.accepts(request.vars, session): id = form.vars.id regards mmlado On Thursday 06 August 2009 10:43:26 max wrote: > i am inserting Form values into a postgres database. > For on-the fly

[web2py:27760] Re: Why

2009-08-01 Thread Mladen Milankovic
Hi On Saturday 01 August 2009 16:47:41 Pynthon Pynthon wrote: > Hey > > Maybe I will switch back to Web2Py but I still have some questions :P. > > 1. Why it is here http://pastebin.com/f4c8cd718 db().select(query) and here > http://pastebin.com/m291dbd6d db(query).select? Simply: first parenthes

[web2py:27610] Re: Auto generate field in view ?

2009-07-30 Thread Mladen Milankovic
Hi. IS_IN_SET works alone, not in combination with other validators. Anyway IS_NOT_EMPTY is not required because the field must have one of the values given in IS_IN_SET. try: db.pampa_classificacaocliente.aceita.requires=IS_IN_SET(['Sim', 'Não']) regards mmlado On Thursday 30 July 2009 15:00

[web2py:27539] Re: Syntax error

2009-07-29 Thread Mladen Milankovic
Hi. Problem is in line: db.Field("password", ‘password’,readable=False, label="Password"), It's the ‘ which isn't a real apostrophe. ' this is. It looks like it, but when I copy/pasted your code, syntax highlighting didn't mark it as a string. Try replacing it. regards mmlado On Wednesday 29

[web2py:23197] Re: date field error

2009-06-03 Thread Mladen Milankovic
Hi. You need to define the type of the field, the IS_DATE is only a validator that will check the values before insert/update. Use: db.define_table('users', SQLField('dob', 'date',requires=IS_DATE()), regards mmlado On Wed, Jun 3, 2009 at 4:36 PM, durga wrote: > > Hi, > > i have defined a

[web2py:23180] Re: inserting values in to db fields which are not there in SQLFORM

2009-06-03 Thread Mladen Milankovic
Hi. Do something like this: form = SQLFORM(db(db.company),fields = ['compname','designation','location']) if form.accepts(request.vars, session): db(db.company.id == form.vars.id).update(userid = session.userid) # do something else like redirect if needed The id of the new record can be

[web2py:23170] Re: why id field is displaying in the form?

2009-06-02 Thread Mladen Milankovic
Hi. There's a parameter to SQLFORM, showid which is True by default. Just set it to False. Like: form = SQLFORM(db.users,user,fields=['firstname','lastname'], showid = False) regards mmlado On Wednesday 03 June 2009 08:32:16 durga wrote: > Hi , > > I have created a table for user. to update

[web2py:23107] Re: how to generate combobox for a sqlfield

2009-06-02 Thread Mladen Milankovic
Hi. You don't need the [] brackets. use: db.define_table('user', db.Field('sex', requires = IS_IN_SET(['male', 'female']))) regards mmlado On Tuesday 02 June 2009 13:39:35 durga wrote: > hi > > I would like create a form through SQLFORM in which one of my field to > be generated as combo b

[web2py:20498] Re: Orderby

2009-04-25 Thread Mladen Milankovic
Hi. You'll need to add html for formating in the view. You can also add the XML helper if you want to have html code in the post. Like: {{for post in posts:}} {{=post.titel}} {{=post.time}} {{=XML(post.post)}} {{pass}} regards mmlado On Saturday 25 April 2009 13:0

[web2py:20497] Re: Orderby

2009-04-25 Thread Mladen Milankovic
Hi. For the html editor, wouldn't know to recommend. When you got the post for the blog, just put it into XML() helper. Like: XML(post) This way it won't be escaped. regards mmlado On Saturday 25 April 2009 12:54:44 Pynthon wrote: > BTW, is there also something like a editor for my blog. Becau

[web2py:20495] Re: Orderby

2009-04-25 Thread Mladen Milankovic
13 Pynthon wrote: > But I see that there is also with profiles etc. > > On Apr 25, 12:45 pm, Mladen Milankovic wrote: > > Hi. > > > > You can do something with the auth class. > > Here some tutorial about > > it.http://mdp.cti.depaul.edu/examples/default/tools

[web2py:20492] Re: Orderby

2009-04-25 Thread Mladen Milankovic
Hi. You can do something with the auth class. Here some tutorial about it. http://mdp.cti.depaul.edu/examples/default/tools You can expose only functions for login/logout. Create a user by hand, through web2py admin. Then create controllers/functions that requires authorization. For the safety

[web2py:20489] Re: Orderby

2009-04-25 Thread Mladen Milankovic
Hi. I'm assuming you have some query from where you take the posts. In the select part there's a parameter orderby. To give it to sort it in reverse order just write the sign ~ in front of the orderby parameter. example db(some_query).select(db.table.ALL, orderby = ~db.table.field) regards mml

[web2py:19929] Re: Host name in routes.py

2009-04-17 Thread Mladen Milankovic
Hi. I'm testing things out and I think got a bug. I'm trying to get root on localhost to show /my_app/default/index page and not the example, so I wrote: routes_in = (('^.*?:https?://localhost:[a-z]+ /$', '/my_app/default/index'), ) It didn't work, and I throw in some logging. I watched what

[web2py:19901] Re: Host name in routes.py

2009-04-16 Thread Mladen Milankovic
Hi. Thank you very much. This is more powerful and more useful then what I did. I see I have a lot to learn. regards mmlado On Thursday 16 April 2009 19:57:47 mdipierro wrote: > A request comes in and you want to redirect it to a controller action > filtering by > - IP of client (for example 1

[web2py:19888] Re: Hidden 'root' controller

2009-04-16 Thread Mladen Milankovic
Hi. You can do this with the routes.py file. Something like: routes_in = ( ('^/([^\/]+)/?$', '/app/cont/function/$1'), ) with the patern [^\/]+ I make sure the param doesn't contain / characters. This way if it happens that it's http://my_site/my_app/cont/func it will still work and not redir