[web2py] Re: PostgreSQL connection hangs on insert

2015-05-19 Thread Auden RovelleQuartz
have you tried using the psycopg2 driver?



On Wednesday, May 20, 2015 at 12:38:51 AM UTC-5, Bilal Hasan wrote:
>
> I'm having a very annoying issue where the connection to a PostgreSQL 
> database hangs and I get a "Attempted to connect to this database 5 times 
> unsuccessfully" which renders the whole web application un-usable.
>
> I'm using PostgreSQL 9.3. Web2Py Version 
> 2.8.2-stable+timestamp.2013.11.28.13.54.07
>
> Below is the only code I use for this database. I'm not sure why it's 
> happening.
>
> jobid = sprint.joblist.insert(**mydict)
> sprint.commit()
> result = sprint(sprint.joblist.id==jobid).select()
>
> db.py:
> sprint = 
> DAL('postgres://***:***@138.85.**.**:5432/nds_smart_sprint',pool_size=30)
>
> Updated pg8000 driver to latest version still no luck.
>
> I have to manually terminate the idle connection using "ps aux | grep 
> postgres"
>

-- 
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: Recommended strategy for passing complex query parameters to a REST API

2015-05-19 Thread Massimo Di Pierro
Hello Kevin,

the best way is to make an Ajax request with content type 'application/json' 
and put the JSON search_criteria into the HTTP request body. For example:

curl -H "Content-Type: application/json" - X POST -d "{...}" 
http:///mypage

where {...} is your JSON object. Then in the web2py app

def mypage():
 data = request.post_vars()
 ...

data will contain the parsed JSON as a python object.






On Tuesday, 19 May 2015 19:50:22 UTC-5, ke...@amplifieddevelopment.net 
wrote:
>
> We are developing a RESTful API.  One of our use cases requires that we 
> query a resource with somewhat complex search criteria.  Internally, the 
> search criteria would be represented by a data structure similar to this:
>
> search_criteria = {'date':'5/31/2015',
>'locations':[{'location_name':'Los Angeles',
>  'attendees':10,
>  'services':['Housekeeping','Catering']
> },
> {'location_name':'New York',
>  'attendees':5,
>  'services':['Housekeeping']
> }
>],
>'duration':60
>
> }
>
>
> What would be a recommended strategy for passing complex query parameters to 
> a RESTful API built with web2py?
>
>
> Our short term solution has been to provide simple query parameters that can 
> contain delimited values.  For example:
>
>
> GET  .../api/available_resources/?date=2015-05-31&locations=Los 
> Angeles|New 
> York&attendees=10|5&services=Housekeeping,Catering|Housekeeping&duration=60
>
>
> But, this seems less than ideal.  It is not intuitive that Los Angeles should 
> be associated with 10 attendees and the two specified services.
>
>
> Options we have considered include:
>
>
>- Treating the search criteria as a resource.  Thus, we would first POST 
> the complex search criteria and receive a handle in return.  Then, we would 
> GET available_resources, passing the search criteria handle.  (This seems to 
> be messy regarding how to handle the search criteria.  Is it stored 
> statefully in the session?  Is it written to the database?  When would it get 
> cleaned up?)
>- Treat the search as a command.  We would POST a resource search command 
> with a JSON representation of the search criteria in the body.  
>- Implement oData parsing for the query string.  (While it is true that 
> oData syntax could be constructed to meet the needs, yikes!, that's a lot of 
> overhead for the API consumer and the API parser.)
>
> Are any of these considered best practice?  Or, is there yet another strategy 
> that we could consider?
>
> Many thanks for your help!
>
> Kevin
>
>
>
>

-- 
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: URL structure for a blog (using router?)

2015-05-19 Thread Jean-François Milants
Thanks, Massimo! It's a nice and easy trick.
I'll implement it as soon as possible.



Le lundi 18 mai 2015 19:24:21 UTC+2, Massimo Di Pierro a écrit :
>
> The usual trick is to generate URLs like
>
> https://domain.com/blog/145/this-is-an-article 
> 
>
> where 145 is the id. The slug is just for show.
>
> On Monday, 18 May 2015 12:10:37 UTC-5, Jean-François Milants wrote:
>>
>> I found out that what I'm trying to do is a 'slug', a unique name for all 
>> of my posts.
>> However, I'm worried about the performances of the search of the post in 
>> DB. 
>>
>> For example,  when the user will enter this URL :
>> https://domain.com/blog/this-is-an-article
>>
>> A request will be made in DB to search for the string 'this-is-an-article 
>> '. This should'nt be an issue 
>> for a small DB, but this could become a bottleneck when the DB will grow.
>>
>> How do you guys implement such a thing?
>>
>>
>>
>> Le samedi 16 mai 2015 16:41:36 UTC+2, Jean-François Milants a écrit :
>>>
>>> Hi,
>>>
>>> I'm writing a blog application, which allows me to create new blog post 
>>> and have them listed on a page.
>>>
>>> In database, I have a table called "articles" which contains some field 
>>> (id, title, content_text,...).
>>>
>>> For now, the URL to access to a specific blog post has the following 
>>> structure :
>>>
>>> https://domain.com/blog/readArticle?articleId=23. 
>>>
>>> Where :
>>>
>>>- Blog is the controller
>>>- readArticle() is the function that retrieves the blog article data
>>>- 23 is the ID of the article in the DB
>>>
>>>
>>> This is easy to implement, but no user/SEO friendly.
>>>
>>> I would like to improve the URL structure to something like:
>>> https://domain.com/blog/readArticle?article=this-is-an-article
>>>
>>> or
>>> https://domain.com/blog/this-is-an-article
>>>
>>> ... and I'm looking for the best way to do this.
>>>
>>> Should I modify my backend so that it will search the article based on 
>>> its title (or 'slug').
>>> Or should I use the 'router' in some advanced ways?
>>>
>>> I'm sure a lot of people has already done that. Any ideas or suggestions?
>>>
>>> Thanks!
>>>
>>>

-- 
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] PostgreSQL connection hangs on insert

2015-05-19 Thread Bilal Hasan
I'm having a very annoying issue where the connection to a PostgreSQL 
database hangs and I get a "Attempted to connect to this database 5 times 
unsuccessfully" which renders the whole web application un-usable.

I'm using PostgreSQL 9.3. Web2Py Version 
2.8.2-stable+timestamp.2013.11.28.13.54.07

Below is the only code I use for this database. I'm not sure why it's 
happening.

jobid = sprint.joblist.insert(**mydict)
sprint.commit()
result = sprint(sprint.joblist.id==jobid).select()

db.py:
sprint = 
DAL('postgres://***:***@138.85.**.**:5432/nds_smart_sprint',pool_size=30)

Updated pg8000 driver to latest version still no luck.

I have to manually terminate the idle connection using "ps aux | grep 
postgres"

-- 
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: web2ruby possible?

2015-05-19 Thread Stuart Deal
The question is "Why would you translate web2py to Ruby?"

On Sunday, September 11, 2011 at 11:21:23 AM UTC-7, Ramos wrote:
>
> hello
>
> why not translate web2py to ruby? 
>
> is this a good question or what?
>
>
>
>
>
>  

-- 
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: reset_password dont open form to change password

2015-05-19 Thread Antonio Ladeia

Yes, 

I change many things.

i create a personalized form for this, and I can receive the change 
password link[1] in my email, and I have this code 
1431971387-32ab74e1-26a6-4e91-99f3-e9bb19b9400a 

 
in my DB, but when i click en this link, he dont open a form to change 
email...

I need implement something?

[1] - 
http://127.0.0.1:8000/app/default/user/reset_password/1431971387-32ab74e1-26a6-4e91-99f3-e9bb19b9400a
 


-- 
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] totals in grid?

2015-05-19 Thread Alen Cerovic
Hi,

how to add field totals in grid (or smartgrid) footer, for example sum 
numeric field in footer?

Thank You

-- 
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: gluon import error?

2015-05-19 Thread Auden RovelleQuartz
I found what seems to be a fix:

web2py/gluon/dal.py, 

line 15 is 
{
from pydal.objects import Row, Rows, Table, Query, Expression
}

replacing that with 
{
from pydal.objects import Row, Rows, Table, Query, *Set*, Expression

}

solves the problem


On Tuesday, May 19, 2015 at 11:00:46 PM UTC-5, Auden RovelleQuartz wrote:
>
> here is the traceback:
>
> {
>  cannot import name SetVersionweb2py™Version 
> 2.10.4-stable+timestamp.2015.04.26.15.11.54PythonPython 2.7.3: 
> /usr/bin/python (prefix: /usr)Traceback
>
> 1.
> 2.
> 3.
> 4.
> 5.
> 6.
> 7.
> 8.
> 9.
> 10.
> 11.
> 12.
> 13.
> 14.
> 15.
> 16.
>
> Traceback (most recent call last):
>   File "/home/www-data/web2py/gluon/restricted.py", line 227, in restricted
> exec ccode in environment
>   File 
> "/home/www-data/web2py/applications/omniavx_cxn/controllers/valuecache.py" 
> , 
> line 6897, in 
>   File "/home/www-data/web2py/gluon/globals.py", line 393, in 
> self._caller = lambda f: f()
>   File 
> "/home/www-data/web2py/applications/omniavx_cxn/controllers/valuecache.py" 
> , 
> line 6584, in browse_bacct_callback
> from plugin_PowerGrid.CallBack import CallBack
>   File "/home/www-data/web2py/gluon/custom_import.py", line 95, in 
> custom_importer
> return base_importer(pname, globals, locals, fromlist, level)
>   File "/home/www-data/web2py/gluon/custom_import.py", line 134, in __call__
> result = NATIVE_IMPORTER(name, globals, locals, fromlist, level)
>   File "applications/omniavx_cxn/modules/plugin_PowerGrid/CallBack.py", line 
> 41, in 
> from gluon.dal import Table ,Query, Set, Rows, Row
> ImportError: cannot import name Set
>
> }
>
> same code produces no error in earlier version of web2py
>
> is this a known issue with some workaround available?
>

-- 
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: Recommended strategy for passing complex query parameters to a REST API

2015-05-19 Thread Ron Chatterjee
I have to say, things like this, you can do very well using mongodb. 
Because its json like structure. And then use lower level pymongo to 
do search.find_one(). Idk how DAL will handle such dbase setup.




On Tuesday, May 19, 2015 at 8:50:22 PM UTC-4, 
ke...@amplifieddevelopment.net wrote:
>
> We are developing a RESTful API.  One of our use cases requires that we 
> query a resource with somewhat complex search criteria.  Internally, the 
> search criteria would be represented by a data structure similar to this:
>
> search_criteria = {'date':'5/31/2015',
>'locations':[{'location_name':'Los Angeles',
>  'attendees':10,
>  'services':['Housekeeping','Catering']
> },
> {'location_name':'New York',
>  'attendees':5,
>  'services':['Housekeeping']
> }
>],
>'duration':60
>
> }
>
>
> What would be a recommended strategy for passing complex query parameters to 
> a RESTful API built with web2py?
>
>
> Our short term solution has been to provide simple query parameters that can 
> contain delimited values.  For example:
>
>
> GET  .../api/available_resources/?date=2015-05-31&locations=Los 
> Angeles|New 
> York&attendees=10|5&services=Housekeeping,Catering|Housekeeping&duration=60
>
>
> But, this seems less than ideal.  It is not intuitive that Los Angeles should 
> be associated with 10 attendees and the two specified services.
>
>
> Options we have considered include:
>
>
>- Treating the search criteria as a resource.  Thus, we would first POST 
> the complex search criteria and receive a handle in return.  Then, we would 
> GET available_resources, passing the search criteria handle.  (This seems to 
> be messy regarding how to handle the search criteria.  Is it stored 
> statefully in the session?  Is it written to the database?  When would it get 
> cleaned up?)
>- Treat the search as a command.  We would POST a resource search command 
> with a JSON representation of the search criteria in the body.  
>- Implement oData parsing for the query string.  (While it is true that 
> oData syntax could be constructed to meet the needs, yikes!, that's a lot of 
> overhead for the API consumer and the API parser.)
>
> Are any of these considered best practice?  Or, is there yet another strategy 
> that we could consider?
>
> Many thanks for your help!
>
> Kevin
>
>
>
>

-- 
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] gluon import error?

2015-05-19 Thread Auden RovelleQuartz
here is the traceback:

{
 cannot import name SetVersionweb2py™Version 
2.10.4-stable+timestamp.2015.04.26.15.11.54PythonPython 2.7.3: 
/usr/bin/python (prefix: /usr)Traceback

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.

Traceback (most recent call last):
  File "/home/www-data/web2py/gluon/restricted.py", line 227, in restricted
exec ccode in environment
  File 
"/home/www-data/web2py/applications/omniavx_cxn/controllers/valuecache.py" 
, 
line 6897, in 
  File "/home/www-data/web2py/gluon/globals.py", line 393, in 
self._caller = lambda f: f()
  File 
"/home/www-data/web2py/applications/omniavx_cxn/controllers/valuecache.py" 
, 
line 6584, in browse_bacct_callback
from plugin_PowerGrid.CallBack import CallBack
  File "/home/www-data/web2py/gluon/custom_import.py", line 95, in 
custom_importer
return base_importer(pname, globals, locals, fromlist, level)
  File "/home/www-data/web2py/gluon/custom_import.py", line 134, in __call__
result = NATIVE_IMPORTER(name, globals, locals, fromlist, level)
  File "applications/omniavx_cxn/modules/plugin_PowerGrid/CallBack.py", line 
41, in 
from gluon.dal import Table ,Query, Set, Rows, Row
ImportError: cannot import name Set

}

same code produces no error in earlier version of web2py

is this a known issue with some workaround available?

-- 
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] Recommended strategy for passing complex query parameters to a REST API

2015-05-19 Thread kevin
We are developing a RESTful API.  One of our use cases requires that we 
query a resource with somewhat complex search criteria.  Internally, the 
search criteria would be represented by a data structure similar to this:

search_criteria = {'date':'5/31/2015',
   'locations':[{'location_name':'Los Angeles',
 'attendees':10,
 'services':['Housekeeping','Catering']
},
{'location_name':'New York',
 'attendees':5,
 'services':['Housekeeping']
}
   ],
   'duration':60

}


What would be a recommended strategy for passing complex query parameters to a 
RESTful API built with web2py?


Our short term solution has been to provide simple query parameters that can 
contain delimited values.  For example:


GET  .../api/available_resources/?date=2015-05-31&locations=Los Angeles|New 
York&attendees=10|5&services=Housekeeping,Catering|Housekeeping&duration=60


But, this seems less than ideal.  It is not intuitive that Los Angeles should 
be associated with 10 attendees and the two specified services.


Options we have considered include:


   - Treating the search criteria as a resource.  Thus, we would first POST the 
complex search criteria and receive a handle in return.  Then, we would GET 
available_resources, passing the search criteria handle.  (This seems to be 
messy regarding how to handle the search criteria.  Is it stored statefully in 
the session?  Is it written to the database?  When would it get cleaned up?)
   - Treat the search as a command.  We would POST a resource search command 
with a JSON representation of the search criteria in the body.  
   - Implement oData parsing for the query string.  (While it is true that 
oData syntax could be constructed to meet the needs, yikes!, that's a lot of 
overhead for the API consumer and the API parser.)

Are any of these considered best practice?  Or, is there yet another strategy 
that we could consider?

Many thanks for your help!

Kevin



-- 
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.


Re: [web2py] Re: Sublime Text web2py plugin

2015-05-19 Thread Ron Chatterjee
This is great. I just started looking at sublime text. This is not a web2py 
question but since you are so familiar with sublime Gergely, let me ask the 
question anyway...in sublime, all I see a python terminal. I don't see a 
command prompt or ipython terminal. I have installed the ipython from 
install packages.  How do I add more terminal into sublime? Also, 
integrating Ipython with the project so all the variable shows up in the 
workspace. Any thoughts?
 

On Tuesday, May 19, 2015 at 5:00:58 AM UTC-4, Gergely Orosz wrote:
>
> Hi Ramos,
>
> It some bug in SublimeREPL it is not related the W2P plugin.
> I was away on holiday and the development slowed down a bit but I am going 
> to make a tutorial video how to use the plugin
> Also started implementing the open controller from view command
>
>
> 2015. május 7., csütörtök 15:15:09 UTC+2 időpontban Ramos a következőt 
> írta:
>>
>> if i open console i see this before installing SublimeREPL
>>
>> warning: mnemonic r not found in menu caption SublimeREPL
>> warning: mnemonic r not found in menu caption Ruby
>> warning: mnemonic p not found in menu caption Python
>> warning: mnemonic d not found in menu caption Python - PDB current file
>> warning: mnemonic d not found in menu caption Python - RUN current file
>> warning: mnemonic p not found in menu caption Python - IPython
>> warning: mnemonic f not found in menu caption F#
>> warning: mnemonic d not found in menu caption GDB
>> warning: mnemonic g not found in menu caption Groovy
>> warning: mnemonic h not found in menu caption Haskell
>> warning: mnemonic i not found in menu caption Io
>> warning: mnemonic l not found in menu caption Lua
>> warning: mnemonic m not found in menu caption Matlab
>> warning: mnemonic m not found in menu caption MozRepl
>> warning: mnemonic n not found in menu caption Node
>> warning: mnemonic o not found in menu caption Octave
>> warning: mnemonic p not found in menu caption Perl
>> warning: mnemonic s not found in menu caption PHP
>> warning: mnemonic p not found in menu caption PowerShell
>> warning: mnemonic r not found in menu caption R
>> warning: mnemonic n not found in menu caption Racket
>> warning: mnemonic r not found in menu caption Rails
>> warning: mnemonic b not found in menu caption SBT for opened folder
>> warning: mnemonic r not found in menu caption Scheme
>> warning: mnemonic r not found in menu caption Gauche
>> warning: mnemonic r not found in menu caption Petite Chez Scheme
>> warning: mnemonic scs not found in menu caption ScriptCS
>> warning: mnemonic s not found in menu caption Shell
>> Opening in new tab
>> Stoping web2py server with pid: 6192
>> Opening in new tab
>>
>>
>> Then clicking to install sublimeREPL nothing happens
>>  i see only in status bar
>> *"Loading repositories" *
>> and as soon this messages disappears nothing happens and going back to 
>> search to install, there it is again in the list
>>
>> W2P:Add sublimeREPL Support
>>
>>
>>
>>
>>
>>
>>
>>
>> 2015-05-06 18:18 GMT+01:00 Gergely Orosz :
>>
>>> Can you see any error on Sublime Console when run any command?
>>>
>>>
>>> 2015. május 6., szerda 16:12:36 UTC+2 időpontban JorgeH a következőt 
>>> írta:

 I installed in win 7.

 Haven´t been able to get it working.

 On Wednesday, May 6, 2015 at 7:09:38 AM UTC-5, Gergely Orosz wrote:
>
> You should use command palette again
> Search for SublimeREPL: Web2py {your application name}
> It should start interactive console for your web2py application
>
> 2015. május 6., szerda 12:34:17 UTC+2 időpontban Ramos a következőt 
> írta:
>>
>> On more question.
>> i installed sublime repl but how do i get the web2py interactive 
>> console ?
>>
>> thank u
>>
>> 2015-05-06 11:25 GMT+01:00 António Ramos :
>>
>>> From the controller i can open the view
>>>
>>> From the view i should open the controller , not the view again...
>>>
>>> thank u
>>>
>>> 2015-05-06 11:22 GMT+01:00 António Ramos :
>>>
 I have seen the light

 Keep working on it. Its very good...

 2015-05-06 10:06 GMT+01:00 Gergely Orosz :

> Once you installed the plugin restart Sublime Text
> After that you can use the command palette to check the available 
> commands
> All prefixed all web2py related command with W2P 
> if you press CTRL+SHIFT+P and start type W2P you will see all the 
> available commands
>
> 2015. május 6., szerda 10:44:20 UTC+2 időpontban Ramos a 
> következőt írta:
>>
>> Thank you
>> You say it can start and stop the server ...
>> how ?
>>
>> 2015-05-06 6:52 GMT+01:00 Gergely Orosz :
>>
>>> Hi Ramos,
>>>
>>> You should add a web2py application folder to a Sublime Text 
>>> prokeject
>>> 1. Open Sublime go to the Project menu

[web2py] Re: Using mongo engine Field type

2015-05-19 Thread Ron Chatterjee
I am looking at this link:

http://blog.mongodb.org/post/27907941873/using-the-python-toolkit-ming-to-accelerate-your

 I am looking at the imperative style and its so similar to DAL. Do we have 
an interface between ming and DAL. That will bridge the gap I am sure.

# "Imperative" styleBlogPost = collection(
   'blog.posts', session, 
   Field('_id', S.ObjectId),
   Field('posted', datetime, if_missing=datetime.utcnow),
   Field('title', str),
   Field('author', User),
   Field('text', str),
   Field('comments', [ 
   dict(author=User,
posted=S.DateTime(if_missing=datetime.utcnow),
text=str) ]))





On Monday, May 18, 2015 at 5:53:41 PM UTC-4, Ron Chatterjee wrote:
>
> Is there a way to use mongo engine field type (ODM) directly inside 
> web2py. I know in django (ORM) I can use a document class instead of the 
> model. For example:
>
>
> #---
>
> from mongoengine import Document, StringField, DateTimeField
> import datetime
>
>
> class Post(Document):
>  title = StringField(max_length=200, required=True)
> content = StringField(required=True)
> date_published = DateTimeField(default=datetime.datetime.now, 
> required=True)
>
>
> #--
>
>
>   MongoEngine field type Django ORM equivalent Web2py DAL equivalent  
> StringField CharField string  URLField URLField IS_URL  EmailField 
> EmailField IS_EMAIL  IntField IntegerField integer  FloatField FloatField 
> N/A  DecimalField DecimalField N/A  BooleanField BooleanField Boolean  
> DateTimeField DateTimeField datetime  EmbeddedDocumentField None
> DictField NoneListField None list:string  SortedListField None
> BinaryField None N/A  ObjectIdField NoneFileField FileField upload  
>
>
>

-- 
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.


Re: [web2py] IS_IN_DB() multiple tables

2015-05-19 Thread kecajkecaj123
Rich, 

Can You have a quick look at this? 

Thanks, 

On Tuesday, 12 May 2015 17:34:38 UTC+2, kecajk...@gmail.com wrote:
>
> Sure, it's pretty simple:
>
> DB:
>
> db.define_table('ipaddress',
>Field('ip', unique=True, length=200,requires=IS_NOT_EMPTY()),
>Field('status', length=200, default="Free", 
> requires=IS_IN_SET(['Free','Used'])),
>format = '%(ip)s')
>
> db.define_table('server',
>Field('servername', length=200),
>Field('ipaddress', unique=True, length=200, 
> requires=IS_IN_DB(db(db.ipaddress.status=='Free'),db.ipaddress.ip, 
> '%(ip)s')))
>
> def __after_insert_server(f, id):
> db(db.ipaddress.ip == f.ipaddress).update(status = T('Used') )
>
>
> def __before_delete_server(s):
> db(db.ipaddress.ip == s.select()[0].ipaddress).update(status = T('Free')) 
>
> 
> def __before_update_server(s,f):
> db(db.ipaddress.ip == s.select()[0].ipaddress).update(status = 
> T('Free'))
> db(db.ipaddress.ip == f['ipaddress']).update(status = T('Used') )
> 
> db.server._after_insert.append(__after_insert_server)
> db.server._before_delete.append(__before_delete_server)
> db.server._before_update.append(__before_update_server)
>
>
> GRID:
>
> def temp():
>   
> query=(db.server.id>0 )
> fields=()
> grid = SQLFORM.grid(query=query,fields=fields,user_signature=False)
> 
> return dict(grid=grid)
>
>
>
>
> On Monday, 11 May 2015 15:49:10 UTC+2, Richard wrote:
>>
>> Ok, so the problem is that when you edit your record the dropbox field 
>> shouldn't be blank... That is your issue, would you share the code of you 
>> form and grid and the exact validators...
>>
>> There shoud be something that don't work somewhere...
>>
>> And it you may start here : requires=IS_IN_DB(db(db.ipadd
>> ress.status=='Free'),db.ipaddress.ip, '%(ip)s')),
>>
>> It should read :
>>
>> requires=IS_IN_DB(db(db.ipaddress.status=='Free'),* 'ipaddr**ess.ip'*, 
>> '%(ip)s')),
>>
>>
>>
>> Richard
>>
>> On Mon, May 11, 2015 at 9:14 AM, 黄祥  wrote:
>>
>>> why not use conditional requires base on url?
>>> e.g.
>>> if 'free' in request.controllers:
>>>
>>>
>>>
>>> On Monday, May 11, 2015 at 4:19:03 PM UTC+7, kecajk...@gmail.com wrote:

 Richard, 

 Let say that I have two IPs in ipaddress table:

 10.1.1.1  FREE
 10.2.2.2 FREE

 I add a server into server table, i put name as server1 and chose IP 
 from dropdown menu 10.1.1.1.
 Then my ipaddress table looks like that
 10.1.1.1 USED
 10.2.2.2 FREE

 But i noticed that i did a typo in server name... in fact server name 
 should be server111, so i use grid to display server table and use update 
 button next to "server1" record. I change server name to server111 and i 
 need to chose an IP again (as IP dropdown field is blank). So now i would 
 like to chose same IP as before, but I'm not able to do it, because 
 dropdown shows just 10.2.2.2 which make sense as i used 

  requires=IS_IN_DB(db(db.ipaddress.status=='Free'),db.ipaddress.ip, 
 '%(ip)s')),

 So my question is how to make IP 10.1.1.1 visiable on the list when i'm 
 updating the record? 

 Regards.

 On Thursday, 7 May 2015 15:52:07 UTC+2, Richard wrote:
>
> Ok, I don't understand... Can you go back one step and explain what 
> kind of information you want to manage and why you think you have to 
> update 
> the IP address... Is there multiple records with the same server name if 
> so 
> why... It seems to me that you want to manage kind of history of IP 
> attached to a given device... If so, you DB schema is not sufficient, you 
> will need an archive table which will contains the old state of your 
> server 
> record... In your server table there will be only a single record for 
> each 
> of your server and in the history table when you update this single 
> record 
> the old state of the record will be copied there, so you can track all 
> the 
> IP a given server had in the past... An history table is easy achieve in 
> web2py with record versioning...
>
> Richard
>
> On Thu, May 7, 2015 at 6:52 AM,  wrote:
>
>> Hi, 
>>
>> What's the difference between what i wrote and what You wrote? 
>> And i believe You didn't get my point. Checking if IP is Free works 
>> correctly. Point is that i want do update the one row in Server table 
>> and 
>> change i.e. server name. I click on update button provided by grid, and 
>> i 
>> can change the name of the server (withouth changing its IP), but i need 
>> to 
>> chose an IP as well. Problem is that on the IP list, IP i used for that 
>> server before is marked as Used, so i won't see it on the list and i 
>> can't 
>> chose it again. How to make it available for selection while i'm 
>> updating 
>> the row.
>>
>> Thanks
>> On Wednesday, 6 May 2015 16:52:0

Re: [web2py] Re: Sublime Text web2py plugin

2015-05-19 Thread Gergely Orosz
Hi Ramos,

It some bug in SublimeREPL it is not related the W2P plugin.
I was away on holiday and the development slowed down a bit but I am going 
to make a tutorial video how to use the plugin
Also started implementing the open controller from view command


2015. május 7., csütörtök 15:15:09 UTC+2 időpontban Ramos a következőt írta:
>
> if i open console i see this before installing SublimeREPL
>
> warning: mnemonic r not found in menu caption SublimeREPL
> warning: mnemonic r not found in menu caption Ruby
> warning: mnemonic p not found in menu caption Python
> warning: mnemonic d not found in menu caption Python - PDB current file
> warning: mnemonic d not found in menu caption Python - RUN current file
> warning: mnemonic p not found in menu caption Python - IPython
> warning: mnemonic f not found in menu caption F#
> warning: mnemonic d not found in menu caption GDB
> warning: mnemonic g not found in menu caption Groovy
> warning: mnemonic h not found in menu caption Haskell
> warning: mnemonic i not found in menu caption Io
> warning: mnemonic l not found in menu caption Lua
> warning: mnemonic m not found in menu caption Matlab
> warning: mnemonic m not found in menu caption MozRepl
> warning: mnemonic n not found in menu caption Node
> warning: mnemonic o not found in menu caption Octave
> warning: mnemonic p not found in menu caption Perl
> warning: mnemonic s not found in menu caption PHP
> warning: mnemonic p not found in menu caption PowerShell
> warning: mnemonic r not found in menu caption R
> warning: mnemonic n not found in menu caption Racket
> warning: mnemonic r not found in menu caption Rails
> warning: mnemonic b not found in menu caption SBT for opened folder
> warning: mnemonic r not found in menu caption Scheme
> warning: mnemonic r not found in menu caption Gauche
> warning: mnemonic r not found in menu caption Petite Chez Scheme
> warning: mnemonic scs not found in menu caption ScriptCS
> warning: mnemonic s not found in menu caption Shell
> Opening in new tab
> Stoping web2py server with pid: 6192
> Opening in new tab
>
>
> Then clicking to install sublimeREPL nothing happens
>  i see only in status bar
> *"Loading repositories" *
> and as soon this messages disappears nothing happens and going back to 
> search to install, there it is again in the list
>
> W2P:Add sublimeREPL Support
>
>
>
>
>
>
>
>
> 2015-05-06 18:18 GMT+01:00 Gergely Orosz  >:
>
>> Can you see any error on Sublime Console when run any command?
>>
>>
>> 2015. május 6., szerda 16:12:36 UTC+2 időpontban JorgeH a következőt írta:
>>>
>>> I installed in win 7.
>>>
>>> Haven´t been able to get it working.
>>>
>>> On Wednesday, May 6, 2015 at 7:09:38 AM UTC-5, Gergely Orosz wrote:

 You should use command palette again
 Search for SublimeREPL: Web2py {your application name}
 It should start interactive console for your web2py application

 2015. május 6., szerda 12:34:17 UTC+2 időpontban Ramos a következőt 
 írta:
>
> On more question.
> i installed sublime repl but how do i get the web2py interactive 
> console ?
>
> thank u
>
> 2015-05-06 11:25 GMT+01:00 António Ramos :
>
>> From the controller i can open the view
>>
>> From the view i should open the controller , not the view again...
>>
>> thank u
>>
>> 2015-05-06 11:22 GMT+01:00 António Ramos :
>>
>>> I have seen the light
>>>
>>> Keep working on it. Its very good...
>>>
>>> 2015-05-06 10:06 GMT+01:00 Gergely Orosz :
>>>
 Once you installed the plugin restart Sublime Text
 After that you can use the command palette to check the available 
 commands
 All prefixed all web2py related command with W2P 
 if you press CTRL+SHIFT+P and start type W2P you will see all the 
 available commands

 2015. május 6., szerda 10:44:20 UTC+2 időpontban Ramos a következőt 
 írta:
>
> Thank you
> You say it can start and stop the server ...
> how ?
>
> 2015-05-06 6:52 GMT+01:00 Gergely Orosz :
>
>> Hi Ramos,
>>
>> You should add a web2py application folder to a Sublime Text 
>> prokeject
>> 1. Open Sublime go to the Project menu
>> 2. Choose Add folder to project option
>> 3. Browse your web2py application you like to work on
>>
>> You are ready to use the W2P plugin
>>
>> I am going to make the video tutorial on the weekend and also 
>> going to update the plugin read with these steps
>>
>> Thank you letting me know
>>
>> 2015. május 5., kedd 13:16:36 UTC+2 időpontban Ramos a következőt 
>> írta:
>>>
>>> i installed it and get the message to add web2py to the project
>>>
>>> what project?
>>>
>>> you should do a 1 minute video to show how to use it
>