Re: [web2py] adding an item in a list:reference :

2012-04-02 Thread Manuele Pesenti

Il 01/04/2012 23:23, bussiere adrien ha scritto:

ok i see the example :
  db.define_table('tag',Field('name'),format='%(name)s')
  db.define_table('product',
 Field('name'),
 Field('tags','list:reference tag'))
  a=db.tag.insert(name='red')
  b=db.tag.insert(name='green')
  c=db.tag.insert(name='blue')
  db.product.insert(name='Toy Car',tags=[a,b,c])
*but if after i make :*
d=db.tag.insert(name='purple')

how to add d to db.product ? with a,b,c who were already here ?


I use to:

1. extract the values in a variable
2. append the new value to the list variable
3. update the value in table

M.



Regards
Bussiere

*
*




[web2py] grid without

2012-04-02 Thread Manuele Pesenti

Hi,
is there an easy way to use grid and smartgrid without the delete 
botton? I mean I want to only use the deleting option from the update 
form not the botton in the table because in this case no callback 
function are performed ( 
http://code.google.com/p/web2py/issues/detail?id=651)


I've had a look of the SQLFORM.grid code in sqlhtml.py but at the moment 
I didn't realize how to solve it so I need to by pass.


thanks

Manuele


[web2py] Returning JSON data to a GWT client app

2012-04-02 Thread Carl
I'm looking at the example StockWatcher.java from GWT modified to use JSON 
and call a Web2py server app.

In the client app I'm 
using: http://127.0.0.1:8000/init/default/stockPrices.json?q=ABC
note the .json extension.

In my default.py in Web2py I have:
def stockPrices():
sym = request.vars['q']
rows = db(db.stock_price).select()
prices = rows.find(lambda row: row.symbol in sym).as_list()
return json.dumps(prices)

Is there an approach in Web2py I can use that I don't need to call 
json.dumps() when returning prices ? What are others doing?


Re: [web2py] grid without

2012-04-02 Thread Manuele Pesenti

Il 02/04/2012 11:06, Johann Spies ha scritto:

Use 'deletable=False' in the argurments for the grid.

Documented at 
http://www.web2py.com/books/default/chapter/29/7#SQLFORM.grid-and-SQLFORM.smartgrid-%28experimental%29



Regards
Johann

Hi Johann,
thanks for your replay but that's not what I'm looking for. I want to 
delete records just through the update form as explained in the email. 
In this way I have to write a controller dedicated to record deletion...


cheers

M.


[web2py] Routes.py parameter, rewrite rules and redirect

2012-04-02 Thread Joseph.Piron
Hi all, 

For one of my applications, I use web2py as a rest backend for a extjs 
application. So, in order to redirect to this app, I have 
def index():

example action using the internationalization operator T and flash
rendered by views/default/index.html or views/generic.html

redirect(URL(a=request.application, c='static', f='index.html'))


The problem is I want to have only the server name in the url so I added a 
routes.py with 
routers = dict(
 BASE = dict(
 default_application = webmoni,
 applications = ['webmoni','admin'],
 controllers = 'DEFAULT'
 )
)

but it seems that the redirect neglects the default_application removal 
attempt from the url. 
How can I achieve this ? (not to 
have https://webmoni/webmoni/static/index.html as displayed url)

Moreover, I did try the domains option but there were no way for me to get 
access to the admin app?
Could anyone give an example with port 80 to app and 443 to admin using 
domains option ?

Thanks in advance !!!



[web2py] Re: Routes.py parameter, rewrite rules and redirect

2012-04-02 Thread Joseph.Piron
Ah, and another simple question, maybe dull.. :)

Does the domains option have any use when web2py's app is served from a 
apache or nginx frontend by wsgi ?

Le lundi 2 avril 2012 11:57:37 UTC+2, Joseph.Piron a écrit :

 Hi all, 

 For one of my applications, I use web2py as a rest backend for a extjs 
 application. So, in order to redirect to this app, I have 
 def index():
 
 example action using the internationalization operator T and flash
 rendered by views/default/index.html or views/generic.html
 
 redirect(URL(a=request.application, c='static', f='index.html'))


 The problem is I want to have only the server name in the url so I added a 
 routes.py with 
 routers = dict(
  BASE = dict(
  default_application = webmoni,
  applications = ['webmoni','admin'],
  controllers = 'DEFAULT'
  )
 )

 but it seems that the redirect neglects the default_application removal 
 attempt from the url. 
 How can I achieve this ? (not to have 
 https://webmoni/webmoni/static/index.html as displayed url)

 Moreover, I did try the domains option but there were no way for me to get 
 access to the admin app?
 Could anyone give an example with port 80 to app and 443 to admin using 
 domains option ?

 Thanks in advance !!!



Re: [web2py] Returning JSON data to a GWT client app

2012-04-02 Thread Michele Comitini
Carl,

You may find the @service.json annotation useful.
Try the following:
  return dict(prices=prices)

Il 02 aprile 2012 11:08, Carl m...@carlroach.com ha scritto:
 I'm looking at the example StockWatcher.java from GWT modified to use JSON
 and call a Web2py server app.

 In the client app I'm
 using: http://127.0.0.1:8000/init/default/stockPrices.json?q=ABC
 note the .json extension.

 In my default.py in Web2py I have:
 def stockPrices():
     sym = request.vars['q']
     rows = db(db.stock_price).select()
     prices = rows.find(lambda row: row.symbol in sym).as_list()
     return json.dumps(prices)

 Is there an approach in Web2py I can use that I don't need to call
 json.dumps() when returning prices ? What are others doing?


Re: [web2py] Re: grid without delete botton

2012-04-02 Thread Martín Mulone
use the parameter deletable=False

SQLFORM.grid(...deletable=False ... )

2012/4/2 Manuele Pesenti manuele.pese...@gmail.com

 excuse me I forgot to complete the object...

 Il 02/04/2012 10:46, Manuele Pesenti ha scritto:

 Hi,
 is there an easy way to use grid and smartgrid without the delete botton?
 I mean I want to only use the deleting option from the update form not the
 botton in the table because in this case no callback function are performed
 ( 
 http://code.google.com/p/**web2py/issues/detail?id=651http://code.google.com/p/web2py/issues/detail?id=651
 )

 I've had a look of the SQLFORM.grid code in sqlhtml.py but at the moment
 I didn't realize how to solve it so I need to by pass.

 thanks

Manuele





-- 
 http://www.tecnodoc.com.ar


Re: [web2py] Returning JSON data to a GWT client app

2012-04-02 Thread Carl Roach
thanks Michele

alas that change returns invalid view (default/stockPrices.html)
presumably because there is no view or no view with prices defined.

I'm looking for something that allows my existing Pyjamas app and new GWT
app to call the same functions. That gives me a good way to test the new
GWT app as I'll have a working Pyjamas app alongside.

On 2 April 2012 11:34, Michele Comitini michele.comit...@gmail.com wrote:

 Carl,

 You may find the @service.json annotation useful.
 Try the following:
  return dict(prices=prices)

 Il 02 aprile 2012 11:08, Carl m...@carlroach.com ha scritto:
  I'm looking at the example StockWatcher.java from GWT modified to use
 JSON
  and call a Web2py server app.
 
  In the client app I'm
  using: http://127.0.0.1:8000/init/default/stockPrices.json?q=ABC
  note the .json extension.
 
  In my default.py in Web2py I have:
  def stockPrices():
  sym = request.vars['q']
  rows = db(db.stock_price).select()
  prices = rows.find(lambda row: row.symbol in sym).as_list()
  return json.dumps(prices)
 
  Is there an approach in Web2py I can use that I don't need to call
  json.dumps() when returning prices ? What are others doing?



Re: [web2py] Re: grid without delete botton

2012-04-02 Thread Manuele Pesenti

Il 02/04/2012 12:41, Martín Mulone ha scritto:

use the parameter deletable=False

SQLFORM.grid(...deletable=False ... )
but in this way I cannot delete record at all from the grid, neither 
from the update form that it generates.
The fact is that I need to setup some ondelete function for every record 
deleted but it's by-passes if the deletion is performed directly from 
the delete button in the grid.


thanks

Manuele


[web2py] Re: Multiple custom SQLFORMs on a page only able to submit one.

2012-04-02 Thread Sushant Taneja
I also checked using chrome developer tools that the div which contains 
the _formkey and _formname is not getting generated (missing from HTML). 
May be that is the reason the form is not working.

What may be the reason for this ? and what is a feasible solution ? 

On Monday, April 2, 2012 10:55:51 AM UTC+5:30, Sushant Taneja wrote:

 Hi,

 I tried with form.validate() and also with form.process().accepted. Can 
 you provide some sample code on how do I achieve the above ?
 I am already providing the name of the form while declaring it. How is it 
 different from web2py generated _formname ?

 On Monday, April 2, 2012 5:07:14 AM UTC+5:30, Anthony wrote:

 In the method which defines the registration form, I return upload_form 
 alongside as :

 return(reg_form=reg_form,upload_form=upload_form)

 The problem is that the _formkey and _formname hidden fields are created 
 when you call form.accepts() -- so you have to call form.accepts() both 
 when the form is first created and returned to the view and when the form 
 is submitted. The form object that you are returning to the view does not 
 include those hidden fields, but the form processing code in upload_image() 
 is expecting those fields to be there. Also, it is recommended that you use 
 the newer form.process() or form.validate() API rather than form.accepts().

 Anthony



Re: [web2py] Returning JSON data to a GWT client app

2012-04-02 Thread Michele Comitini
Carl,

Try the code below for plain json.
For pyjamas you can use jsonrpc it works well with web2py.
See the web2py book to learn how to use the @service annotation.

def call():
  session.forget()
  return service()

@service.json
def stockPrices(q):
sym = q
rows = db(db.stock_price).select()
prices = rows.find(lambda row: row.symbol in sym).as_list()
return dict(prices=prices)

then call it like:

http://127.0.0.1:8000/init/default/call/stockPrices?q=ABC

mic


Il 02 aprile 2012 12:44, Carl Roach m...@carlroach.com ha scritto:
 thanks Michele

 alas that change returns invalid view (default/stockPrices.html)
 presumably because there is no view or no view with prices defined.

 I'm looking for something that allows my existing Pyjamas app and new GWT
 app to call the same functions. That gives me a good way to test the new GWT
 app as I'll have a working Pyjamas app alongside.


 On 2 April 2012 11:34, Michele Comitini michele.comit...@gmail.com wrote:

 Carl,

 You may find the @service.json annotation useful.
 Try the following:
  return dict(prices=prices)

 Il 02 aprile 2012 11:08, Carl m...@carlroach.com ha scritto:
  I'm looking at the example StockWatcher.java from GWT modified to use
  JSON
  and call a Web2py server app.
 
  In the client app I'm
  using: http://127.0.0.1:8000/init/default/stockPrices.json?q=ABC
  note the .json extension.
 
  In my default.py in Web2py I have:
  def stockPrices():
      sym = request.vars['q']
      rows = db(db.stock_price).select()
      prices = rows.find(lambda row: row.symbol in sym).as_list()
      return json.dumps(prices)
 
  Is there an approach in Web2py I can use that I don't need to call
  json.dumps() when returning prices ? What are others doing?




Re: [web2py] Re: data source configuration

2012-04-02 Thread Carlos Correia
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Em 31-03-2012 07:17, Alex escreveu:
 ok, I think now I understand how the request_tenant works. So there would be
 just one database for everything but every table is filtered by the field? If
 that is the case that's really not what I want.
 
 I also thought about selecting the db by the request.env.http_host etc. this
 also seems like a hack to me but I guess I could live with that... only 
 problem
 is this will not work with cron jobs (accessing the db), at least that is 
 what I
 assume. I'm currently using enviroment variables for the db config but this
 fails now because of the cron jobs (external cron).
 
 I'm now thinking of reading the db config from a config file in db.py but this
 also seems like a really bad solution. Then I'd probably have the file I/O for
 every request just to get the db configuration.
 

I'm facing the same problem as you (the 'all-in-one' solution doesn't fit
either) and the best solution I found so far was to read the DB connection
parameters based on a config file.

The drawback is that you have to read that file on each request... one day I'll
try to figure how to cache it.

An alternative might be a script that changed the URI in models/db.py, like this
one from Francisco Ribeiro:
http://www.web2pyslices.com/slice/show/1472/deployment-script-with-inline-code-replacement


 Am Samstag, 31. März 2012 03:05:27 UTC+2 schrieb nick name:
 
 The database connection is initialized in models/db.py (assuming you used
 the wizard to generate your application). Look for the line that says
 db=DAL(...), and make it select the right database according to your
 request, e.g. request.host, or however else you determine the 
 configuration
 environment.
 
 Alternatively, you could keep it all in the same database with a
 request_tenant' field:
 https://groups.google.com/d/topic/web2py/CixV2qflqkk/discussion -
 
 if you add a field such as the following to a table:
 
 ...
Field('request_tenant', default=request.host),
 ...
 (where the default is however you identify the specific environment)
 
 web2py will add a and request_tenant=''+request.host+'' to every query
 relating to that table, and of course would insert it to new records.
 Effectively, this means every record in a table with such a field will 
 only
 be seen when the default value of the field in this request is the same as
 when it was generated. (You can still get all records by either setting 
 the
 default to None, or adding an ignore_common_filter=True)
 
 On Friday, March 30, 2012 4:55:16 PM UTC-4, Alex wrote:
 
 Hello,
 
 I need to configure my data source for different instances. Currently
 this is the last problem preventing me from going productive. I run my
 application for multiple customer instances and of course the database
 connection is different for each customer. This issue also occurs if 
 you
 have a test and a productive environment. I think this is a fairly
 common use case and necessary for most real world applications, so I'm
 really surprised that I didn't see any solution for this in web2py
 (especially since web2py is so easy and powerful for everything else).
 Or did I just miss something?
 
 Massimo, in case you read this, do you have an advice for me? is an
 environment configuration a feature that could be added in the 
 future? I
 think that I read somewhere that web2py developers don't think this is
 necessary but I really don't understand why.
 
 Is there a workaround for me? I have some ideas but nothing seems to 
 be
 optimal. I'd prefer to avoid dirty hacks...
 
 thanks,
 Alex
 


- -- 
Com os melhores cumprimentos,

Carlos Correia
=
MEMÓRIA PERSISTENTE, Lda.
Tel.: 219 291 591 - GSM:  917 157 146 / 967 511 762
e-mail: ge...@memoriapersistente.pt - URL: http://www.memoriapersistente.pt
Jabber: m...@jabber.org
GnuPG: wwwkeys.eu.pgp.net
URL Suporte (experimental): https://ky.m16e.com (certificado auto-assinado)
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk95aPsACgkQ90uzwjA1SJUfHACeMsGn4Npt70baxB9ZJkuUanIJ
EO0AoMlxgT+3Hwc323vzcaqyXjvebGx6
=ASOO
-END PGP SIGNATURE-


Re: [web2py] Re: grid without delete botton

2012-04-02 Thread Manuele Pesenti

Il 02/04/2012 12:41, Martín Mulone ha scritto:

use the parameter deletable=False

SQLFORM.grid(...deletable=False ... )

ok I solved at the moment using

deletable = 'edit' in request.args
SQLFORM.grid(...deletable=deletable ... )

thanks

Manuele


[web2py] Older facebook clone application issue

2012-04-02 Thread rif
The facebook clone application contains some code that is not supported on 
appengine:

   tokens = form.vars.name.split()

query = reduce(lambda a,b:ab, 
[User.first_name.contains(k)|User.last_name.contains(k) for k in tokens])
people = db(query).select(orderby=alphabetical)


Is there any recommended workarount to this kind of search on gae?

Moreover http://web2py.appspot.com/friends/default/home will issue a crash 
ticket after login. Maybe it should be checked and fixed if the application 
is still online on web2py appspot.

-rif


[web2py] Re: web2py recommended web hosting

2012-04-02 Thread Yarin
As of March 2012 GAE supports neither relational DBs nor SSL on custom 
domains- making it a nonstarter for any production app I can think of. 

On Monday, March 7, 2011 6:46:01 PM UTC-5, Richard Penman wrote:

 Unless you need special features I recommend Google App Engine because 
 there is no upfront costs and easy to deploy.



[web2py] Re: Routes.py parameter, rewrite rules and redirect

2012-04-02 Thread Anthony
If you want the default app removed from static URLs, you have to set 
map_static=True in your router 
(see http://code.google.com/p/web2py/source/browse/router.example.py#64). 
However, if your web server (e.g., Apache) is set up to serve static files 
directly, you don't want to re-write your outgoing static urls unless your 
server knows how to map them as incoming urls.

Anthony

On Monday, April 2, 2012 5:57:37 AM UTC-4, Joseph.Piron wrote:

 Hi all, 

 For one of my applications, I use web2py as a rest backend for a extjs 
 application. So, in order to redirect to this app, I have 
 def index():
 
 example action using the internationalization operator T and flash
 rendered by views/default/index.html or views/generic.html
 
 redirect(URL(a=request.application, c='static', f='index.html'))


 The problem is I want to have only the server name in the url so I added a 
 routes.py with 
 routers = dict(
  BASE = dict(
  default_application = webmoni,
  applications = ['webmoni','admin'],
  controllers = 'DEFAULT'
  )
 )

 but it seems that the redirect neglects the default_application removal 
 attempt from the url. 
 How can I achieve this ? (not to have 
 https://webmoni/webmoni/static/index.html as displayed url)

 Moreover, I did try the domains option but there were no way for me to get 
 access to the admin app?
 Could anyone give an example with port 80 to app and 443 to admin using 
 domains option ?

 Thanks in advance !!!



Re: [web2py] Re: Routes.py parameter, rewrite rules and redirect

2012-04-02 Thread Joseph Piron
Nice!

I am gonna try that !

On 02 Apr 2012, at 14:50, Anthony wrote:

 If you want the default app removed from static URLs, you have to set 
 map_static=True in your router (see 
 http://code.google.com/p/web2py/source/browse/router.example.py#64). However, 
 if your web server (e.g., Apache) is set up to serve static files directly, 
 you don't want to re-write your outgoing static urls unless your server knows 
 how to map them as incoming urls.
 
 Anthony
 
 On Monday, April 2, 2012 5:57:37 AM UTC-4, Joseph.Piron wrote:
 Hi all, 
 
 For one of my applications, I use web2py as a rest backend for a extjs 
 application. So, in order to redirect to this app, I have 
 def index():
 
 example action using the internationalization operator T and flash
 rendered by views/default/index.html or views/generic.html
 
 redirect(URL(a=request.application, c='static', f='index.html'))
 
 
 The problem is I want to have only the server name in the url so I added a 
 routes.py with 
 routers = dict(
  BASE = dict(
  default_application = webmoni,
  applications = ['webmoni','admin'],
  controllers = 'DEFAULT'
  )
 )
 
 but it seems that the redirect neglects the default_application removal 
 attempt from the url. 
 How can I achieve this ? (not to have 
 https://webmoni/webmoni/static/index.html as displayed url)
 
 Moreover, I did try the domains option but there were no way for me to get 
 access to the admin app?
 Could anyone give an example with port 80 to app and 443 to admin using 
 domains option ?
 
 Thanks in advance !!!
 



[web2py] Re: Multiple custom SQLFORMs on a page only able to submit one.

2012-04-02 Thread Anthony


 I tried with form.validate() and also with form.process().accepted. Can 
 you provide some sample code on how do I achieve the above ?
 I am already providing the name of the form while declaring it. How is it 
 different from web2py generated _formname ?


Your original code simply set the name attribute of the HTML form 
element (i.e., SQLFORM(..., _name=...)). However, that doesn't affect the 
_formname hidden element. To set that, you have to set the formname 
argument to the accepts() method (or process() or validate()).  Anyway, I'm 
not sure you need to set your own formname -- web2py will automatically 
generate a formname based on the db table name and type of form, so two 
forms on the same page based on different tables will have different names 
anyway. 
See http://web2py.com/books/default/chapter/29/7#Multiple-forms-per-page.

Anthony


[web2py] Re: Multiple custom SQLFORMs on a page only able to submit one.

2012-04-02 Thread Anthony


 I also checked using chrome developer tools that the div which contains 
 the _formkey and _formname is not getting generated (missing from HTML). 
 May be that is the reason the form is not working.

 What may be the reason for this ? and what is a feasible solution ?


Sounds like you're not calling form.accepts (or .process or .validate) when 
the form is first created before returning it to the view. It might help if 
you show your current code.

Anthony


[web2py] Re: Routes.py parameter, rewrite rules and redirect

2012-04-02 Thread Anthony


 However, if your web server (e.g., Apache) is set up to serve static files 
 directly, you don't want to re-write your outgoing static urls unless your 
 server knows how to map them as incoming urls.


FYI, I think that's why map_static defaults to False -- the assumption is 
that web2py will not be handling static file serving in production (and in 
most cases, static files are not full web pages whose URLs are shown in the 
browser address bar, with the possible exception of error pages).

Anthony 


Re: [web2py] Re: Deployment sqlite question

2012-04-02 Thread Ruben Orduz
Thanks for link, I'll check it out.

And yeah it's totally risky, but it's more to prove a point that
automated deployment works with a small app rather than full-sized
deployment.

On Mon, Apr 2, 2012 at 1:02 AM, pbreit pbreitenb...@gmail.com wrote:
 That seems risky to automatically pull in changes but I guess it could work.
 In general, I think it should work fine what you are doing. Can you let us
 know the exact error message?

 One issue you can run into with SQLite is that I believe you can't drop
 columns and then re-add them. Maybe that's the issue?
 http://web2py.com/books/default/chapter/29/6#Fixing-broken-migrations



[web2py] Re: Multiple custom SQLFORMs on a page only able to submit one.

2012-04-02 Thread Sushant Taneja
Thanks Anthony. 

But as I stated above, the problem is the div element which contains the 
_formname and _formkey is not getting generated on the page for the image 
upload form and I think that it might be creating the problem.

What can be the reason for it ?


On Monday, April 2, 2012 6:29:41 PM UTC+5:30, Anthony wrote:

 I tried with form.validate() and also with form.process().accepted. Can 
 you provide some sample code on how do I achieve the above ?
 I am already providing the name of the form while declaring it. How is it 
 different from web2py generated _formname ?


 Your original code simply set the name attribute of the HTML form 
 element (i.e., SQLFORM(..., _name=...)). However, that doesn't affect the 
 _formname hidden element. To set that, you have to set the formname 
 argument to the accepts() method (or process() or validate()).  Anyway, 
 I'm not sure you need to set your own formname -- web2py will automatically 
 generate a formname based on the db table name and type of form, so two 
 forms on the same page based on different tables will have different names 
 anyway. See 
 http://web2py.com/books/default/chapter/29/7#Multiple-forms-per-page.

 Anthony



[web2py] Re: Multiple custom SQLFORMs on a page only able to submit one.

2012-04-02 Thread Anthony


 But as I stated above, the problem is the div element which contains the 
 _formname and _formkey is not getting generated on the page for the image 
 upload form and I think that it might be creating the problem.

 What can be the reason for it ?


Did you see my other reply? It sounds like you are not calling form.accepts 
(or .process or .validate) when the form is initially created. It will help 
if you show your current code.

Anthony 


Re: [web2py] Routes.py parameter, rewrite rules and redirect

2012-04-02 Thread Jonathan Lundell
On Apr 2, 2012, at 2:57 AM, Joseph.Piron wrote:
 For one of my applications, I use web2py as a rest backend for a extjs 
 application. So, in order to redirect to this app, I have 
 def index():
 
 example action using the internationalization operator T and flash
 rendered by views/default/index.html or views/generic.html
 
 redirect(URL(a=request.application, c='static', f='index.html'))
 
 
 The problem is I want to have only the server name in the url so I added a 
 routes.py with 
 routers = dict(
  BASE = dict(
  default_application = webmoni,
  applications = ['webmoni','admin'],
  controllers = 'DEFAULT'
  )
 )
 
 but it seems that the redirect neglects the default_application removal 
 attempt from the url. 
 How can I achieve this ? (not to have 
 https://webmoni/webmoni/static/index.html as displayed url)

The static 'controller' is a special case. It's not mapped by default, to make 
it easier for external (server) rewrites. Add map_static = True to your router 
to accomplish what you're after. (Also, 'static' can never be the default 
controller.)

 
 Moreover, I did try the domains option but there were no way for me to get 
 access to the admin app?
 Could anyone give an example with port 80 to app and 443 to admin using 
 domains option ?

domains = {
domain.com:80  : app,
domain.com:443 : admin,
},

However, the stock /app/appadmin does things like this:

URL('admin', 'default', 'design', args=[request.application])

...and that will cause you problems, because it won't generate a secure access. 
What ought to work in this example would be the following, in all cases in 
which URL refers to admin (I haven't tested this):

URL('admin', 'default', 'design', args=[request.application], 
scheme='https')

Re: [web2py] Re: Routes.py parameter, rewrite rules and redirect

2012-04-02 Thread Jonathan Lundell
On Apr 2, 2012, at 3:27 AM, Joseph.Piron wrote:
 Ah, and another simple question, maybe dull.. :)
 
 Does the domains option have any use when web2py's app is served from a 
 apache or nginx frontend by wsgi ?

Maybe.

There are two reasons (that I can think of) why it might not. One is whether 
the frontend server is serving the requests to a shared instance (or set of 
shared instances) of web2py. If different domains go to dedicated web2py 
instances, there'd be no point in domain routing in web2py. Also, you might 
want to do your domain-to-application rewriting in the frontend server, in 
which case it wouldn't be useful in web2py. There's of course overlap between 
those two conditions.

FWIW, from the router's point of view, Rocket is just another wsgi frontend 
server.

Re: [web2py] adding an item in a list:reference :

2012-04-02 Thread bussiere adrien
ok i thought about this too.
But when you have a long list 
that's not really nice.
And it take twolines.

Summon Massimo can't we make a one line methode to do that ?



Regards and thanks
Bussiere

Le lundi 2 avril 2012 10:00:23 UTC+2, Manuele a écrit :

 Il 01/04/2012 23:23, bussiere adrien ha scritto:
  ok i see the example :
db.define_table('tag',Field('name'),format='%(name)s')
db.define_table('product',
   Field('name'),
   Field('tags','list:reference tag'))
a=db.tag.insert(name='red')
b=db.tag.insert(name='green')
c=db.tag.insert(name='blue')
db.product.insert(name='Toy Car',tags=[a,b,c])
  *but if after i make :*
  d=db.tag.insert(name='purple')
 
  how to add d to db.product ? with a,b,c who were already here ?

 I use to:

 1. extract the values in a variable
 2. append the new value to the list variable
 3. update the value in table

  M.

 
  Regards
  Bussiere
 
  *
  *



Re: [web2py] Re: 10.24$ reward for a recipe logging a user

2012-04-02 Thread selecta
I am not able to find out how to email you in private o_O

On Tuesday, March 27, 2012 12:06:43 AM UTC+2, bussiere adrien wrote:

 It work 

 Thanks
 Just mail me in private where to give
 Bussiere

 Le lundi 26 mars 2012 20:23:06 UTC+2, selecta a écrit :

 if it works please donate to the web2py project




Re: [web2py] Re: Routes.py parameter, rewrite rules and redirect

2012-04-02 Thread Joseph Piron
Indeed, makes sense.
Thanks for the confirmation :)

On 02 Apr 2012, at 16:02, Jonathan Lundell wrote:

 On Apr 2, 2012, at 3:27 AM, Joseph.Piron wrote:
 Ah, and another simple question, maybe dull.. :)
 
 Does the domains option have any use when web2py's app is served from a 
 apache or nginx frontend by wsgi ?
 
 Maybe.
 
 There are two reasons (that I can think of) why it might not. One is whether 
 the frontend server is serving the requests to a shared instance (or set of 
 shared instances) of web2py. If different domains go to dedicated web2py 
 instances, there'd be no point in domain routing in web2py. Also, you might 
 want to do your domain-to-application rewriting in the frontend server, in 
 which case it wouldn't be useful in web2py. There's of course overlap between 
 those two conditions.
 
 FWIW, from the router's point of view, Rocket is just another wsgi frontend 
 server.



Re: [web2py] Returning JSON data to a GWT client app

2012-04-02 Thread Carl Roach
yes... I've been using @service.json and my Pyjamas app can call such
decorated and retrieve json-formatted data. all I need to do is return
{'tag1', data1', 'tag2', data2}

I now want to know how I can get a GWT app to call the same function.
Anyone using GWT with Web2py?


On 2 April 2012 11:34, Michele Comitini michele.comit...@gmail.com wrote:

 Carl,

 You may find the @service.json annotation useful.
 Try the following:
  return dict(prices=prices)

 Il 02 aprile 2012 11:08, Carl m...@carlroach.com ha scritto:
  I'm looking at the example StockWatcher.java from GWT modified to use
 JSON
  and call a Web2py server app.
 
  In the client app I'm
  using: http://127.0.0.1:8000/init/default/stockPrices.json?q=ABC
  note the .json extension.
 
  In my default.py in Web2py I have:
  def stockPrices():
  sym = request.vars['q']
  rows = db(db.stock_price).select()
  prices = rows.find(lambda row: row.symbol in sym).as_list()
  return json.dumps(prices)
 
  Is there an approach in Web2py I can use that I don't need to call
  json.dumps() when returning prices ? What are others doing?



Re: [web2py] Re: How to Represent a Foreign Key Using Foreign Keys in Primary Table

2012-04-02 Thread Patrick Ryan
No dice. I think I'm going to take your original advice and build a
reference table, though. Thanks again for your help.

On Fri, Mar 30, 2012 at 9:13 PM, Derek sp1d...@gmail.com wrote:

 I see what you mean. In that case, you don't want to reference the other
 table, since you don't have a many to many table.
 For many to many relationships, you should have three tables.

 table_one
 table_two
 table_relationship_between_one_and_two

 But if you just want a list of the strings like so:   '%(first)s -
 %(second)s Against %(third)s'
 What you wrote should work, based on what it says in the documentation,
 the defaults should be sufficient. You can try this -- add:

 db.table_two.requires=IS_IN_DB(db,table_one.id, db.table_one._format,
 multiple=True)

 That's just explicitly defining what should be the default...

 On Friday, March 30, 2012 1:49:12 PM UTC-7, pjryan126 wrote:

 Derek:

 Thanks for your response. It's a many-to-many relationship between
 table_one and table_two. i was hoping to denormalize this relationship with
 list:reference, but maybe it's more trouble than it's worth in this case.

 On Friday, March 30, 2012 3:38:23 PM UTC-4, pjryan126 wrote:

 I have the following two tables:

 db.define_table('table_one',
 Field('first', db.first, '%(name)s'),
 Field('second', db.second, '%(name)s'),
 Field('third', db.third, '%(name)s'),
 format = '%(first)s - %(second)s Against %(third)s')

 db.define_table('table_two',
 Field('fourth', db.fourth),
 Field('fifth', db.fifth),
 Field('table_ones', 'list:reference table_one'),
 Field('sixth', list:string)

 When I go to add a record to the db.form table in appadmin, the
 db.form.plan_classes drop-down box populates using the id's in the
 respective db.table_one fields (i.e., 1 - 1 Against 2, etc).

 How would I get the items in the db.table_two.table_ones list to appear
 in a drop-down box using the field representations assigned in the
 db.table_one table definition? Any help on this would be greatly
 appreciated!




Re: [web2py] CkEditor Edit in Place

2012-04-02 Thread Ovidio Marinho
http://www.web2pyslices.com/slice/show/1345/using-ckeditor-for-text-fields



   Ovidio Marinho Falcao Neto
Web Developer
 ovidio...@gmail.com
  ovidiomari...@itjp.net.br
 ITJP - itjp.net.br
   83   8826 9088 - Oi
   83   9334 0266 - Claro
Brasil




2012/4/1 Hassan Alnatour halna...@gardeniatelco.com

 Dear ALL ,

 i am trying to use the edit in place method in ckeditor but , i need an
 example of how to make the function the refers to from the url() , as i
 understand i need to make a function the saves the content in the database
 but its w textarea how can i get the text in the controller


 To make this content editable, all it takes is the following line in the
 view:

 {{=ckeditor.edit_in_place('.editable', URL())}}




[web2py] LDAP Query for more details

2012-04-02 Thread Shiv
Hi Team

I am doing ldap authentication in my application.
Now, i want to get more information from the LDAP like First name, last 
name, contact info.

Can any one guide me to achieve the same?

Thanks  Regards
Shiv


[web2py] Deployment web2py Snow Leopard Server error

2012-04-02 Thread Mobility
I am new to Web2py. I tried to deploy it on my Snow Leopard Server running 
Mac OS X Server 10.6.8. I have already installed on the server the wsgi 
module which I use with a Django app.

I installed web2py on the server following the guidelines on the deployment 
chapter of the Web2py Book (4th ed). The steps I took were:

1. Created an user and group www-data using WorkGroup Manager;
2. Created a virtual host web2py.mobility-br.com on the server;
3. Downloaded the web2py source with the curl -O command;
4. Installed on the wwwdata directory;
5. Added the port 80 apache configuration lines to the 
web2py.mobility-br.com conf file using a include line;
6. restarted the web service. No error on the server.

When I try to access the site I get the following message:

Internal errorTicket issued: 
unrecoverablehttp://web2py.mobility-br.com/admin/default/ticket/unrecoverable

When I click on the link unrecoverable another page opens with:

Access forbidden!

You don't have permission to access the requested object. It is either 
read-protected or not readable by the server.

If you think this is a server error, please contact the 
webmasterad...@example.com
.
Error 403web2py.mobility-br.com
Mon Apr 2 06:58:27 2012
Apache/2.2.21 (Unix) mod_python/3.3.1 Python/2.6.1 mod_ssl/2.2.21 
OpenSSL/0.9.8r DAV/2 mod_wsgi/3.3 PHP/5.3.8 SVN/1.6.17

In the error.log file I get the following error message:

[Fri Mar 30 07:13:49 2012] [error] ERROR:web2py:Traceback (most recent call 
last):
[Fri Mar 30 07:13:49 2012] [error]   File 
/Users/wwwdata/web2py/gluon/main.py, line 394, in wsgibase
[Fri Mar 30 07:13:49 2012] [error] socket.gethostbyname(http_host)]
[Fri Mar 30 07:13:49 2012] [error] gaierror: [Errno 8] nodename nor 
servname provided, or not known

Thanks for your help



[web2py] Re: LDAP Query for more details

2012-04-02 Thread szimszon
http://www.web2pyslices.com/slice/show/1476/ldap-auth-with-allowed-groups-and-manage-groups

You should get trunk version.

2012. április 2., hétfő 18:39:06 UTC+2 időpontban Shiv a következőt írta:

 Hi Team

 I am doing ldap authentication in my application.
 Now, i want to get more information from the LDAP like First name, last 
 name, contact info.

 Can any one guide me to achieve the same?

 Thanks  Regards
 Shiv



[web2py] Re: LDAP Query for more details

2012-04-02 Thread Derek
And this one specifically for Active Directory...
http://www.web2pyslices.com/slice/show/1484/ldap-with-groups-yes-another-recipe
 


On Monday, April 2, 2012 9:39:06 AM UTC-7, Shiv wrote:

 Hi Team

 I am doing ldap authentication in my application.
 Now, i want to get more information from the LDAP like First name, last 
 name, contact info.

 Can any one guide me to achieve the same?

 Thanks  Regards
 Shiv



Re: [web2py] Returning JSON data to a GWT client app

2012-04-02 Thread Michele Comitini
Just to clarify things :

JSONRPC!=JSON

jsonrpc is a json specialization used as protocol to call remote
procedures.  web2py can be used to publish *jsonrpc* services using
@service.jsonrpc

mic
Il giorno 02/apr/2012 16:33, Carl Roach m...@carlroach.com ha scritto:

 yes... I've been using @service.json and my Pyjamas app can call such
 decorated and retrieve json-formatted data. all I need to do is return
 {'tag1', data1', 'tag2', data2}

 I now want to know how I can get a GWT app to call the same function.
 Anyone using GWT with Web2py?


 On 2 April 2012 11:34, Michele Comitini michele.comit...@gmail.comwrote:

 Carl,

 You may find the @service.json annotation useful.
 Try the following:
  return dict(prices=prices)

 Il 02 aprile 2012 11:08, Carl m...@carlroach.com ha scritto:
  I'm looking at the example StockWatcher.java from GWT modified to use
 JSON
  and call a Web2py server app.
 
  In the client app I'm
  using: http://127.0.0.1:8000/init/default/stockPrices.json?q=ABC
  note the .json extension.
 
  In my default.py in Web2py I have:
  def stockPrices():
  sym = request.vars['q']
  rows = db(db.stock_price).select()
  prices = rows.find(lambda row: row.symbol in sym).as_list()
  return json.dumps(prices)
 
  Is there an approach in Web2py I can use that I don't need to call
  json.dumps() when returning prices ? What are others doing?





Re: [web2py] Re: data source configuration

2012-04-02 Thread Derek


 @cache('key', 5000, cache.ram)


that's how you cache it...



On Monday, April 2, 2012 1:53:15 AM UTC-7, Carlos Correia wrote:

 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1

 Em 31-03-2012 07:17, Alex escreveu:
  ok, I think now I understand how the request_tenant works. So there 
 would be
  just one database for everything but every table is filtered by the 
 field? If
  that is the case that's really not what I want.
  
  I also thought about selecting the db by the request.env.http_host etc. 
 this
  also seems like a hack to me but I guess I could live with that... only 
 problem
  is this will not work with cron jobs (accessing the db), at least that 
 is what I
  assume. I'm currently using enviroment variables for the db config but 
 this
  fails now because of the cron jobs (external cron).
  
  I'm now thinking of reading the db config from a config file in db.py 
 but this
  also seems like a really bad solution. Then I'd probably have the file 
 I/O for
  every request just to get the db configuration.
  

 I'm facing the same problem as you (the 'all-in-one' solution doesn't fit
 either) and the best solution I found so far was to read the DB connection
 parameters based on a config file.

 The drawback is that you have to read that file on each request... one day 
 I'll
 try to figure how to cache it.

 An alternative might be a script that changed the URI in models/db.py, 
 like this
 one from Francisco Ribeiro:

 http://www.web2pyslices.com/slice/show/1472/deployment-script-with-inline-code-replacement


  Am Samstag, 31. März 2012 03:05:27 UTC+2 schrieb nick name:
  
  The database connection is initialized in models/db.py (assuming you 
 used
  the wizard to generate your application). Look for the line that says
  db=DAL(...), and make it select the right database according to 
 your
  request, e.g. request.host, or however else you determine the 
 configuration
  environment.
  
  Alternatively, you could keep it all in the same database with a
  request_tenant' field:
  https://groups.google.com/d/topic/web2py/CixV2qflqkk/discussion -
  
  if you add a field such as the following to a table:
  
  ...
 Field('request_tenant', default=request.host),
  ...
  (where the default is however you identify the specific environment)
  
  web2py will add a and request_tenant=''+request.host+'' to every 
 query
  relating to that table, and of course would insert it to new records.
  Effectively, this means every record in a table with such a field 
 will only
  be seen when the default value of the field in this request is the 
 same as
  when it was generated. (You can still get all records by either 
 setting the
  default to None, or adding an ignore_common_filter=True)
  
  On Friday, March 30, 2012 4:55:16 PM UTC-4, Alex wrote:
  
  Hello,
  
  I need to configure my data source for different instances. 
 Currently
  this is the last problem preventing me from going productive. I 
 run my
  application for multiple customer instances and of course the 
 database
  connection is different for each customer. This issue also 
 occurs if you
  have a test and a productive environment. I think this is a 
 fairly
  common use case and necessary for most real world applications, 
 so I'm
  really surprised that I didn't see any solution for this in 
 web2py
  (especially since web2py is so easy and powerful for everything 
 else).
  Or did I just miss something?
  
  Massimo, in case you read this, do you have an advice for me? is 
 an
  environment configuration a feature that could be added in the 
 future? I
  think that I read somewhere that web2py developers don't think 
 this is
  necessary but I really don't understand why.
  
  Is there a workaround for me? I have some ideas but nothing 
 seems to be
  optimal. I'd prefer to avoid dirty hacks...
  
  thanks,
  Alex
  


 - -- 
 Com os melhores cumprimentos,

 Carlos Correia
 =
 MEMÓRIA PERSISTENTE, Lda.
 Tel.: 219 291 591 - GSM:  917 157 146 / 967 511 762
 e-mail: ge...@memoriapersistente.pt - URL: 
 http://www.memoriapersistente.pt
 Jabber: m...@jabber.org
 GnuPG: wwwkeys.eu.pgp.net
 URL Suporte (experimental): https://ky.m16e.com (certificado 
 auto-assinado)
 -BEGIN PGP SIGNATURE-
 Version: GnuPG v1.4.11 (GNU/Linux)
 Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

 iEYEARECAAYFAk95aPsACgkQ90uzwjA1SJUfHACeMsGn4Npt70baxB9ZJkuUanIJ
 EO0AoMlxgT+3Hwc323vzcaqyXjvebGx6
 =ASOO
 -END PGP SIGNATURE-



[web2py] Replacing uploaded file with new file - anybody got a better way?

2012-04-02 Thread Cliff
I'm thinking something like this:

# Model ###
db.define_table('things',
  Field('Name',),
  Field('document', upload, requires=IS_UPLOAD_FILENAME(extension='odt', 
lastdot=True)),
)

#Controller ##
def edit():
  record = db.things[request.args(0)]
  form = SQLFORM(db.things, rcrd)
  if form.process().accepted:
if form.vars.document != record.document:
  import os
  os.remove(response.folder+record.document)
response.flash = 'bla bla'
...
  


[web2py] Re: FORM SELECT

2012-04-02 Thread Anthony
See 
http://stackoverflow.com/questions/8146260/best-practice-for-populating-dropdown-based-on-other-dropdown-selection-in-web2p/8152910#8152910.
 
Also, SQLField() has been deprecated in favor of Field().

Anthony

On Monday, April 2, 2012 2:38:51 PM UTC-4, visuallinux wrote:

 Dear All.

 I have the followings on models:


 db.define_table('province',
SQLField('name', 'string', length=50, required=True, 
 default=None))

 db.define_table('cities',
SQLField('name', 'string', length=50, required=True),
SQLField('id_province',db.province, 
 required=IS_IN_SET(db.province)))

 db.define_table('customer',
SQLField('name', 'string', length=50, required=True),
SQLField('id_province',db.province, 
 required=IS_IN_SET(db.province)),
   SQLField('id_cities',db.cities, required=IS_IN_SET(db.cities)))


 I need to implement a FORM for create customers so when i selected a 
 options in SELECT province the SELECT cities automatically add the cities 
 that belong to the province SELECTED.

 Any idea how i can do?

 Fernando.



[web2py] Re: FORM SELECT

2012-04-02 Thread Cliff
May I make a suggestion?

Your model will be simpler like this ...
db.define_table('province',

   SQLField('name', 'string', length=50, required=True, 
default=None))

db.define_table('cities',
   SQLField('name', 'string', length=50, required=True),
   SQLField('id_province',db.province, 
required=IS_IN_SET(db.province)))

db.define_table('customer',
   SQLField('name', 'string', length=50, required=True),
  # Removed id_province field
   SQLField('id_cities',db.cities, required=IS_IN_SET(db.cities)))

The id_province field is redundant and unnecessary.  If you wish to know a 
customer's province, join the tables like this:

# request.args(0) contains the customer's id
((db.customer.id==request.args(0) 
 (db.customer.id_cities==db.cities.id)  
 (db.cities.id_province==db.province.id)
)

On Monday, April 2, 2012 2:38:51 PM UTC-4, visuallinux wrote:

 Dear All.

 I have the followings on models:


 db.define_table('province',
SQLField('name', 'string', length=50, required=True, 
 default=None))

 db.define_table('cities',
SQLField('name', 'string', length=50, required=True),
SQLField('id_province',db.province, 
 required=IS_IN_SET(db.province)))

 db.define_table('customer',
SQLField('name', 'string', length=50, required=True),
SQLField('id_province',db.province, 
 required=IS_IN_SET(db.province)),
   SQLField('id_cities',db.cities, required=IS_IN_SET(db.cities)))


 I need to implement a FORM for create customers so when i selected a 
 options in SELECT province the SELECT cities automatically add the cities 
 that belong to the province SELECTED.

 Any idea how i can do?

 Fernando.



[web2py] Tree view, Rendering

2012-04-02 Thread Simon Ashley
Pretty new to this and stumbling a little. 
We need to generate a Treeview structure with the bottom node ending with 
some links to other pages (graphs etc)

Have a 7 level deep structure (each level in a different table) with each 
level have a table format simple to the following: 
  db.define_table('node', Field('parent',db.parent), Field('node_name'))
  Tables will be maintained using smartgrid

The intention is to use jsTree or similiar loaded/ rendered from a JSON 
response.
(structure could get big so may need to look at some dynamic loading)

Was wondering if there is some sample code/ app that some one is will to 
share to shed some light on which way to go?
(have looked at sqlabs but that's not giving us the fuller picture)

TIA


Re: [web2py] Deployment web2py Snow Leopard Server error

2012-04-02 Thread pbreit
Yes, I suspect you need to chown -R www-data:www-data web2py your web2py 
directory.

Also, if you're just doing development on your mac, you can skip all that 
and just run web2py directly:

$ python web2py.py -a recycle -i 127.0.0.1 -p 8001'


Re: [web2py] Re: LDAP Query for more details

2012-04-02 Thread Shiv
Thanks a lot ... let me try this and get back to you.

On Tue, Apr 3, 2012 at 1:03 AM, Derek sp1d...@gmail.com wrote:

 And this one specifically for Active Directory...

 http://www.web2pyslices.com/slice/show/1484/ldap-with-groups-yes-another-recipe



 On Monday, April 2, 2012 9:39:06 AM UTC-7, Shiv wrote:

 Hi Team

 I am doing ldap authentication in my application.
 Now, i want to get more information from the LDAP like First name, last
 name, contact info.

 Can any one guide me to achieve the same?

 Thanks  Regards
 Shiv




-- 
Thanks  Regards
Shiv


[web2py] Improving scaffolding application

2012-04-02 Thread Hironori Kawano
Hi, actually, I started reading *web2py Application Development Cookbook*
*
*
It talks about improving default scaffolding application by writing 0.py 
file.
My question is, where do I touch to change scaffolding application?

Am I to create 0.py in models in newly created application or is it talking 
about 0.py file under *applications\admin\models* ?

I know the questions sounds specific to a particular book but I would like 
to know how I can override scaffolding app.

Please help me with your expertise.





Re: [web2py] Improving scaffolding application

2012-04-02 Thread Bruno Rocha
This is talking about your custom application, not the admin.

Go to the create new simple application form on admin interface (or do it
by command line using $ python web2py.py -S mynewapp -M)

inside your app you have to create the files needed.

web2py/applications/*mynewapp*/models/0.py



On Mon, Apr 2, 2012 at 11:25 PM, Hironori Kawano h...@genesisk.com wrote:

 Hi, actually, I started reading *web2py Application Development Cookbook*
 *
 *
 It talks about improving default scaffolding application by writing 0.py
 file.
 My question is, where do I touch to change scaffolding application?

 Am I to create 0.py in models in newly created application or is it
 talking about 0.py file under *applications\admin\models* ?

 I know the questions sounds specific to a particular book but I would like
 to know how I can override scaffolding app.

 Please help me with your expertise.






-- 

Bruno Rocha
[http://rochacbruno.com.br]