[web2py] Unable to start web2py: No module named 'globals'

2014-03-21 Thread Deepak Pawar
I downloaded web2py sources from the web2py site, and tried running it as 
mentioned:

E:\Workspace\web2py_src\web2pypython web2py.py
Traceback (most recent call last):
  File web2py.py, line 18, in module
import gluon.widget
  File E:\Workspace\web2py_src\web2py\gluon\__init__.py, line 15, in 
module
from globals import current
ImportError: No module named 'globals'

I have added E:\Workspace\web2py_src\web2py to my PATH. And using python 
3.3.5

E:\Workspace\web2py_src\web2pypython
Python 3.3.5 (v3.3.5:62cf4e77f785, Mar  9 2014, 10:37:12) [MSC v.1600 32 
bit (Intel)] on win32
Type help, copyright, credits or license for more information.



Can someone please guide? What is getting wrong here?

Also, my python installation is not showing me correct values: e.g.

 print sys.path
  File stdin, line 1
print sys.path
^
SyntaxError: invalid syntax

Appreciate any help on this.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: output the name of file stored in table in upload filed?

2013-12-21 Thread deepak sandhu
diva href={{=URL('default', 'download', args=row.files.documentx)}}
{{=row.files.documentx.name}}/a/div

i tried this but still dont work :(

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] output the name of file stored in table in upload filed?

2013-12-20 Thread deepak sandhu
this is view file:

{{for row in rows:}}
diva href={{=URL('default', 'download', args=row.files.documentx)}}
download/a/div
{{pass}}




by doing so I get the download link of all the files one by one but all of 
them are named download which gets confusing to know which one is which. 
So I was trying to output their name:

diva href={{=URL('default', 'download', 
args=row.files.documentx)}}row.files.document.name 
or _name or .str()/a/div



but nothing works. I am sure the name of file is saved and there is a way 
to retrieve it.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] adding dropdown of 3rd table on 2nd table in form

2013-12-20 Thread deepak sandhu
model: 


# coding: utf8
db.define_table('dept',
Field('name',unique=True,label='Department Name'),
format='%(name)s')


db.define_table('course',
Field('dept_id','reference dept'),
   Field('name',unique=True,label='Course Name'),
format='%(name)s')


db.define_table('files',
Field('course_id', 'reference course'),
Field('documentx','upload'))


controller:

def create_doc():
form = SQLFORM(db.files).process(next=URL('show_doc'))
return dict(form = form)



this works perfectly but the problem is when I open create_doc it shows a 
drop-down for courses only which is fine but how can I make it so that it 
asks to select department(in drop-down) then course(in drop-down) and then 
upload the document.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: altering tables and gets database not working. trying to find a way to empty the database.

2013-12-19 Thread deepak sandhu
ok in web2py/applications/notetaker/databases/ directory 
there are many files

1 many files all end with table names i created. (so i think they are 
saving tables which i created in database)
2 sql.log file
3 storage.sqlite

so do you mean to delete all 1 2 3 file or any some particular one?

On Wednesday, December 18, 2013 8:21:07 PM UTC-6, deepak sandhu wrote:

 i made 2 tables in web2py:
 # coding: utf8



 db.define_table('dept',

 Field('name',unique=True))




 db.define_table('course',

 Field('d_id','reference d'),

 Field('name',unique=True))



 then I added some data in them from appadmin. 
 after that I modified the field names of tables since then I am getting 
 errors I can't even see the index page of my application this is the error 
 I get :

 27.0.0.1.2013-12-18.20-14-40.b01e8090-535c-4796-975b-7dd5faa71631
 class 'sqlite3.OperationalError' Cannot add a UNIQUE column

 I was thinking of dropping the tables might solve the problem but in when 
 I open shell it also doest run any commands and keep telling to refresh the 
 page and try again?
 how can I empty the database so I can keep working? 
 I can put the previous definitions of table and fields but I don't 
 remember exactly what I wrote there when I first defined them.

 on removing the unique it works but i dont understand what's the problem 
 with unique? how can i make it working with unique = True



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] how to put the field name with a drop-down instead of its reference id in the form?

2013-12-19 Thread deepak sandhu
this is model x.py:

# coding: utf8
db.define_table('dept',
Field('name',unique=True,label='Department Name'))

db.define_table('course',
Field('dept_id','reference dept'),
Field('name',unique=True,label='Course Name'))


this is is controller x.py:

# create a new department:
def create_dept():
form = SQLFORM(db.dept).process(next=URL('show_dept'))
return dict(form=form)

# list all departments
def show_dept():
rows = db().select(db.dept.ALL)
return dict(rows=rows)

# create new course:
def create_course():
form = SQLFORM(db.course).process(next=URL('show_all_course'))
return dict(form=form)

# list all courses
def show_all_course():
rows = db().select(db.course.ALL)
return dict(rows=rows)

now this is view of x/create_course:

{{extend 'layout.html'}}
h1This is the x/create_course.html template/h1
h2
Enter the name of the course you want to create
/h2
{{=form}}

now my question is - when I create a new course I have to fill in the the 
dept(department) id myself how can I make it a dropdown where the the 
department names are shown and I select a department name and enter the new 
course name and press submit and it creates a new course in that department.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] how can i join 3 tables and output a the all three together joined in web2py?

2013-12-19 Thread deepak sandhu
model:


# coding: utf8
db.define_table('dept',
Field('name',unique=True,label='Department Name'),
format='%(name)s')


db.define_table('course',
Field('dept_id','reference dept'),
Field('name',unique=True,label='Course Name'),
format='%(name)s')


db.define_table('files',
Field('course_id', 'reference course'),
Field('documentx','upload'))




controller:

def show_doc():
rows = db( db.course.id == db.files.course_id , db.dept.id==db.
course.dept_id).select()
return rows




What I am trying to do is joining department with course table and course 
table with files table so when out putting it shows a table with department 
with course and files all together. the solution doest work. it only 
creates a join between course table and files table.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] altering tables and gets database not working. trying to find a way to empty the database.

2013-12-18 Thread deepak sandhu


i made 2 tables in web2py:
# coding: utf8



db.define_table('dept',

Field('name',unique=True))




db.define_table('course',

Field('d_id','reference d'),

Field('name',unique=True))



then I added some data in them from appadmin. 
after that I modified the field names of tables since then I am getting 
errors I can't even see the index page of my application this is the error 
I get :

27.0.0.1.2013-12-18.20-14-40.b01e8090-535c-4796-975b-7dd5faa71631
class 'sqlite3.OperationalError' Cannot add a UNIQUE column

I was thinking of dropping the tables might solve the problem but in when I 
open shell it also doest run any commands and keep telling to refresh the 
page and try again?
how can I empty the database so I can keep working? 
I can put the previous definitions of table and fields but I don't remember 
exactly what I wrote there when I first defined them.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] web2py show() function. (explanation of a line of code)

2013-12-15 Thread deepak sandhu


so this is a function show() which I am trying to understand. in the model 
I do have a db.image table where I stored some images which is pointed in 
the function.

the only line I am not understanding here is

#image = db.image(request.args(0,cast=int))

In request.args(0, cast=int) why it has 0 as argument? and what does 
cast=int does? the complete function is below:

def show():
  image = db.image(request.args(0,cast=int)) or redirect(URL('index'))
  return dict(image=image)

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] using appadmin for other models than db.py in web2py

2013-12-14 Thread deepak sandhu
in web2py we I created a new application called imageblog and in models on 
default I have 2 models :

db.py
menu.py
coffee.py   #this is new one created by me in models i made some tables 
inside this too
and if I use the url 

http://127.0.0.1:8000/imageblog/appadmin/

I can see the appadmin of the db.py model but my question is I created 
another model called 
coffee.py how can I open coffee.py in appadmin?
I tried: 

http://127.0.0.1:8000/imageblog/coffee/appadmin

I get output as : invalid function (coffee/appadmin)
but no luck.
Is appadmin only available for db.py ???

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [web2py] Re: using appadmin for other models than db.py in web2py

2013-12-14 Thread deepak sandhu
perfect it worked I was earlier trying to remove the db definition from
coffee but it used to cause an error  as its should be in alpha numeric
which I was ignoring


On Sat, Dec 14, 2013 at 12:45 PM, Anthony abasta...@gmail.com wrote:

 The problem is that you are defining db = DAL(...) in both coffee.py and
 db.py. Because db.py comes after coffee.py, the db object defined in
 coffee.py is simply replaced by the one defined in db.py, so none of the
 models in coffee.py will be available to any controller, including the
 appadmin controller.

 You should define the db object only once, in the first model file that
 runs (model files run in alphanumeric order).

 Anthony


 On Saturday, December 14, 2013 1:35:16 PM UTC-5, deepak sandhu wrote:

 Its giving me access to models inside db.py but not to models in coffee.py
 I am attaching screenshots of both coffee.py and appadmin  this might
 help to clear.

 inside coffee.py there is just one table

 On Saturday, December 14, 2013 12:22:11 PM UTC-6, Massimo Di Pierro wrote:

 There is only one app for addpadmin:

 http://127.0.0.1:8000/imageblog/appadmin/

 It should give you access to all the models, including coffee.py

 On Saturday, 14 December 2013 12:01:44 UTC-6, deepak sandhu wrote:

 in web2py we I created a new application called imageblog and in models
 on default I have 2 models :

 db.py
 menu.py
 coffee.py   #this is new one created by me in models i made some
 tables inside this too
 and if I use the url

 http://127.0.0.1:8000/imageblog/appadmin/

 I can see the appadmin of the db.py model but my question is I created
 another model called
 coffee.py how can I open coffee.py in appadmin?
 I tried:

 http://127.0.0.1:8000/imageblog/coffee/appadmin

 I get output as : invalid function (coffee/appadmin)
 but no luck.
 Is appadmin only available for db.py ???

  --
 Resources:
 - http://web2py.com
 - http://web2py.com/book (Documentation)
 - http://github.com/web2py/web2py (Source code)
 - https://code.google.com/p/web2py/issues/list (Report Issues)
 ---
 You received this message because you are subscribed to a topic in the
 Google Groups web2py-users group.
 To unsubscribe from this topic, visit
 https://groups.google.com/d/topic/web2py/CrmcJJnDCbc/unsubscribe.
 To unsubscribe from this group and all its topics, send an email to
 web2py+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] i am trying send email using web2py with gmail and using smtp setting i have attached all code

2013-09-30 Thread deepak sandhu


i am trying to create a form in web2py which sends message to an email account 
on submission mainly i used SQLFORM.factory to create the form then i used 
gluon.tools import mail to import the send email functionality. i have set up 
everything i can think of but still on running this code in web2py it gives out 
that fail to send email sorry.

i think the problem is in smtp setting or something. 


from gluon.tools import Mail
mail = Mail()

mail.settings.server = 's...@gmail.com:465'
mail.settings.sender = 'myem...@gmail.com'
mail.settings.login = 'myem...@gmail.com:secret'



def index(): 

form = SQLFORM.factory(
Field('name', requires=IS_NOT_EMPTY()),
Field('email', requires =[ IS_EMAIL(error_message='invalid email!'), 
IS_NOT_EMPTY() ]),
Field('subject', requires=IS_NOT_EMPTY()),
Field('message', requires=IS_NOT_EMPTY(), type='text')
)
if form.process().accepted:
session.name = form.vars.name
session.email = form.vars.email
session.subject = form.vars.subject
session.message = form.vars.message

x = mail.send(to=['otherem...@yahoo.com'],
subject='project minerva',
message= Hello this is an email send from minerva.com from contact 
us form.\nName:+ session.name+ \nEmail :  + session.email +\nSubject : 
+session.subject +\nMessage : +session.message+ .\n 
)

if x == True:
response.flash = 'email sent sucessfully.'
else:
response.flash = 'fail to send email sorry!'

#response.flash = 'form accepted.'
elif form.errors:
response.flash='form has errors.'

return dict(form=form)

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] web2py email setting with smtp not working

2013-09-30 Thread deepak sandhu
here is the code of my controller. 

i am trying to create a form in web2py which sends message to an email 
account on submission mainly i used SQLFORM.factory to create the form then 
i used gluon.tools import mail to import the send email functionality. i 
have set up everything i can think of but still on running this code in 
web2py it gives out that fail to send email sorry.



from gluon.tools import Mail
mail = Mail()

mail.settings.server = 's...@gmail.com:465'
mail.settings.sender = 'myem...@gmail.com'
mail.settings.login = 'myem...@gmail.com:secret'



def index(): 

form = SQLFORM.factory(
Field('name', requires=IS_NOT_EMPTY()),
Field('email', requires =[ IS_EMAIL(error_message='invalid email!'), 
IS_NOT_EMPTY() ]),
Field('subject', requires=IS_NOT_EMPTY()),
Field('message', requires=IS_NOT_EMPTY(), type='text')
)
if form.process().accepted:
session.name = form.vars.name
session.email = form.vars.email
session.subject = form.vars.subject
session.message = form.vars.message

x = mail.send(to=['otherem...@yahoo.com'],
subject='project minerva',
message= Hello this is an email send from minerva.com from contact 
us form.\nName:+ session.name+ \nEmail :  + session.email +\nSubject : 
+session.subject +\nMessage : +session.message+ .\n 
)

if x == True:
response.flash = 'email sent sucessfully.'
else:
response.flash = 'fail to send email sorry!'

#response.flash = 'form accepted.'
elif form.errors:
response.flash='form has errors.'

return dict(form=form)

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: return user defined xml in web2py

2012-10-16 Thread deepak
any updates/help...

-- 





[web2py] Re: return user defined xml in web2py

2012-10-16 Thread deepak
xmlwitch?

xmlwitch works on normal python script. 
Is there a way to return custom made xml from web2py controller.
Can you please help me with some prototype?

On Tuesday, 16 October 2012 13:36:30 UTC+5:30, Niphlod wrote:

 does that work on a normal python script ?

 On Tuesday, October 16, 2012 8:25:18 AM UTC+2, deepak wrote:

 any updates/help...



-- 





[web2py] Re: return user defined xml in web2py

2012-10-16 Thread deepak
Hi Niphlod,

xmlwitch was not able to return the xml object.
I got error:
*TypeError: __repr__ returned non-string (type instance)*

-- 





[web2py] Re: return user defined xml in web2py

2012-10-16 Thread deepak
Hi Niphlod,

xmlwitch was able to print the xml but couldn't return from an method. I 
got issues :
*TypeError: __repr__ returned non-string (type instance)*


-- 





[web2py] access a configuration file into web2py

2012-10-16 Thread deepak
Hi, 
I have a configuration file. I wanted to use ConfigObj library to access 
the configuration file.
I have placed the file inside the controller and tried accessing it like:

cfg=ConfigObj(conf.ini)

It didnt read the file. But when i gave it like this:

cfg=ConfObj(/home/deepak/web2py/applications/depyweb/controller/conf.ini)

it worked!..

What is the issue with this?

-- 





[web2py] return user defined xml in web2py

2012-10-15 Thread deepak
Hi,

1. How do i return user defined XML with custom tags in web2py?


2. I wanted to use xmlwitch but i get the below error when i try to return 
the xml object:
error on line 1 at column 26: Specification mandate value for attribute 
instance

def get_xml():
xml = xmlwitch.Builder(version='1.0', encoding='utf-8')
with xml.feed(xmlns='http://www.w3.org/2005/Atom'):
xml.title('Example Feed')
xml.updated('2003-12-13T18:30:02Z')
response.headers['Content-Type']='text/xml'
#return XML(str(xml),sanitize=True)
#return XML(str(xml)).xml()
return xml

Need some help?

-
Deepak

-- 





[web2py] Re: return user defined xml in web2py

2012-10-15 Thread deepak
3. I wanted to use attributes inside XML tags , thats wy i go for xmlwitch, 
which i feel is so lightweight to use

-- 





[web2py] Re: Using Decorators for RESTful URLs

2012-08-16 Thread deepak
I would like to perform REST Services by mapping url to the 
controller-function. For eg:

@app.route('/')def api_root():
return 'Welcome'
@app.route('/articles')def api_articles():
return 'List of ' + url_for('api_articles')
@app.route('/articles/articleid')def api_article(articleid):
return 'You are reading ' + articleid

which could be done in Flask. Basically i would want to match the URLs to 
the service in web2py.

On Tuesday, 14 August 2012 23:43:20 UTC+5:30, Anthony wrote:

 It looks like you could do all of that with web2py. Can you be more 
 specific regarding how you want your URLs to look and what they should 
 retrieve. In addition to RESTful services and routing, have you looked at 
 the basics: http://web2py.com/books/default/chapter/29/4#Dispatching?

 Anthony

 On Tuesday, August 14, 2012 1:10:58 PM UTC-4, deepak wrote:

 I want to use RESTful URL patters likewise in Flask, '
 http://publish.luisrei.com/articles/flaskrest.html'

 All I could end up finding was to make use of routes.py [routes_in  
 routes_out]. 

 Deepak



-- 





[web2py] Re: Using Decorators for RESTful URLs

2012-08-16 Thread deepak
Anthony and Massimo, I'd really thank you ppl for giving me a solution with 
some code! Thats wonderful!. 
It really helped me get going. Thanks again guys. :)  

Deepak

On Thursday, 16 August 2012 22:37:41 UTC+5:30, Anthony wrote:

 web2py does not use decorators to specify routes like Flask does (which 
 can get cumbersome and difficult to maintain with lots of routes). Instead, 
 first, you get default routing without making any explicit routing 
 specifications -- see the link I posted earlier: 
 http://web2py.com/books/default/chapter/29/4#Dispatching. In web2py, your 
 code translates to:

 In /myapp/controllers/default.py:

 def index():
 return 'Welcome'

 def articles():
 if request.args:
 return 'Your are reading ' + request.args(0)
 else:
 return 'List of ' + URL()

 That will give you URLs like the following:

 /myapp
 /myapp/default/articles
 /myapp/default/articles/1

 Now, to get rid of myapp and default, you can use one of the two 
 web2py URL rewrite 
 systemshttp://web2py.com/books/default/chapter/29/4#URL-rewrite. 
 In this case, the simplest is the parameter-based 
 systemhttp://web2py.com/books/default/chapter/29/4#Parameter-based-system. 
 Just create a routes.py file in the /web2py folder with the following 
 content:

 routers = dict(
 BASE = dict(
 default_application = 'myapp'
 )
 )

 Specifying the default application, controller, and function removes them 
 from the URLs. The default controller and default function are already set 
 to default and index, respectively, so you don't have to specify those 
 explicitly in the router (you would have to specify them if you used 
 different names). So, by creating the routes.py file and adding myapp as 
 the default application, we now get the routes you want:

 /
 /articles
 /articles/1

 Of course, if it's just an API, you don't necessarily need to remove the 
 application and controller name from the URLs. You might instead consider 
 creating a separate api.py controller file with the above index() and 
 articles() functions in it. Then, even without any routes.py file, you 
 would get URLs like:

 /myapp/api
 /myapp/api/articles
 /myapp/api/articles/1

 This is all with web2py's default routing -- no need to specify any routes 
 at all (web2py will automatically look for the index() function when you 
 request a URL with only a controller, like /myapp/api).

 You might also want to look at 
 http://web2py.com/books/default/chapter/29/10#Restful-Web-Services.

 Anthony

 On Thursday, August 16, 2012 5:05:21 AM UTC-4, deepak wrote:

 I would like to perform REST Services by mapping url to the 
 controller-function. For eg:

 @app.route('/')def api_root():
 return 'Welcome'
 @app.route('/articles')def api_articles():
 return 'List of ' + url_for('api_articles')
 @app.route('/articles/articleid')def api_article(articleid):
 return 'You are reading ' + articleid

 which could be done in Flask. Basically i would want to match the URLs to 
 the service in web2py.

 On Tuesday, 14 August 2012 23:43:20 UTC+5:30, Anthony wrote:

 It looks like you could do all of that with web2py. Can you be more 
 specific regarding how you want your URLs to look and what they should 
 retrieve. In addition to RESTful services and routing, have you looked at 
 the basics: http://web2py.com/books/default/chapter/29/4#Dispatching?

 Anthony

 On Tuesday, August 14, 2012 1:10:58 PM UTC-4, deepak wrote:

 I want to use RESTful URL patters likewise in Flask, '
 http://publish.luisrei.com/articles/flaskrest.html'

 All I could end up finding was to make use of routes.py [routes_in  
 routes_out]. 

 Deepak



-- 





[web2py] Re: Using Decorators for RESTful URLs

2012-08-16 Thread deepak
I just want to know how to create URL pattern in routes.py, what i really 
want to understand is, how to parse parameters in URL patterns like the 
one, Massimo showed in his example -- 

*('/article/(?Pid\d+)' , '/appname/default/article/$id')*

*(?Pid\d+)  *
*
*
I would be really helpful if I could get any references.

Deepak

On Thursday, 16 August 2012 22:48:10 UTC+5:30, Massimo Di Pierro wrote:

 I would recommend Anthony's solution but you can do something similar like 
 this:

 1) create a file routes.py with
 #  begin 
 routes_in = [
  ('/' , '/appname/default/api_root'),
  ('/articles' , '/appname/default/api_articles'),
  ('/article/(?Pid\d+)' , '/appname/default/article/$id')]

 routes_out=[(b,a) for (a,b) in routes_in]
 # --- end ---

 then in your default.py controller you can do:

 def api_root():
 return 'Welcome'

 def api_articles():
 return 'List of ' + URL('api_articles')

 def api_article():
 articleid = request.args(0,cast=int)
 return 'You are reading ' + articleid

 you can also do

 @request.restful
 def api_article():
 def GET(articleid):
  return 'You are reading ' + articleid
 return locals()


 Massimo

 On Thursday, 16 August 2012 04:05:21 UTC-5, deepak wrote:

 I would like to perform REST Services by mapping url to the 
 controller-function. For eg:

 @app.route('/')def api_root():
 return 'Welcome'
 @app.route('/articles')def api_articles():
 return 'List of ' + url_for('api_articles')
 @app.route('/articles/articleid')def api_article(articleid):
 return 'You are reading ' + articleid

 which could be done in Flask. Basically i would want to match the URLs to 
 the service in web2py.

 On Tuesday, 14 August 2012 23:43:20 UTC+5:30, Anthony wrote:

 It looks like you could do all of that with web2py. Can you be more 
 specific regarding how you want your URLs to look and what they should 
 retrieve. In addition to RESTful services and routing, have you looked at 
 the basics: http://web2py.com/books/default/chapter/29/4#Dispatching?

 Anthony

 On Tuesday, August 14, 2012 1:10:58 PM UTC-4, deepak wrote:

 I want to use RESTful URL patters likewise in Flask, '
 http://publish.luisrei.com/articles/flaskrest.html'

 All I could end up finding was to make use of routes.py [routes_in  
 routes_out]. 

 Deepak



-- 





[web2py] Using Decorators for RESTful URLs

2012-08-14 Thread deepak
Hi all,

Could anybody help me give a heads up on how to use RESTful service with URL 
decorators in web2py?

Deepak

-- 





[web2py] Re: Using Decorators for RESTful URLs

2012-08-14 Thread deepak
I want to use RESTful URL patters likewise in Flask, '
http://publish.luisrei.com/articles/flaskrest.html'

 All I could end up finding was to make use of routes.py [routes_in  
routes_out]. 

Deepak

--