Re: [web2py] Re: Sublime Text web2py plugin

2015-05-05 Thread 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
>
> thank u
>
> 2015-05-05 7:43 GMT+01:00 Gergely Orosz  >:
>
>> Thank you Massimo,
>>
>> I am going to improve it continuously
>>
>> 2015. május 4., hétfő 18:24:34 UTC+2 időpontban Massimo Di Pierro a 
>> következőt írta:
>>>
>>> Nice. Thank you! I added link form the web2py examples/ app.
>>>
>>> On Monday, 4 May 2015 05:28:55 UTC-5, Gergely Orosz wrote:

 Hi 4 All,

 I've started to develop a web2py plugin for Sublime Text 3.
 I've implemented a few command I found very useful on my daily work.
 If you have any idea how can I make it better and useful please visit 
 the below link and submit your feature request there
 Thanks in advance

 You can find the plugin: https://bitbucket.org/kfog/w2p

 If you have any question please feel free to ask here or on the Issue 
 tracker

 All the best
 Greg

>>>  -- 
>> 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+un...@googlegroups.com .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
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: Singletons Save Memory and Time

2015-05-05 Thread Joe Barnhart
I don't want to cache the entire output of the function.  If I do that, the 
cache will include the data in the table.  I just want to save the object 
that generates the table and apply new data to it for each user / swimmer / 
whatever.  

Had I used cache.ram on this table, it would have made Natalie Coughlin's 
times a permanent feature of the cached output.  With the Singleton 
approach, I can click on Michael Phelps name and re-use the same object 
that generates the table, but with different table contents.

With cache.ram, I would eventually cache separate versions of the table for 
every swimmer I ever looked at.  Or at least within the given cache 
timeframe.

On Tuesday, May 5, 2015 at 5:42:41 PM UTC-7, Leonel Câmara wrote:
>
> Why not just use cache ram?
>

-- 
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: Singletons Save Memory and Time

2015-05-05 Thread Joe Barnhart
The jQuery Datatables library is very impressive.  It handles sorting, 
filtering, displaying of data in all forms.  Its really worth a look at 
http://datatables.net  My application is very data-centric and I use a LOT 
of tables, so I built some datatable factory methods to help me.


On Tuesday, May 5, 2015 at 4:31:33 PM UTC-7, Dave S wrote:
>
>
>  Just to make sure I understand what I'm looking at,
> the widget in the image has 3 sortable columns in the current tab, and a 
> second tab as well?
>
>

-- 
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: Singletons Save Memory and Time

2015-05-05 Thread Leonel Câmara
Why not just use cache ram?

-- 
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: How to display SVG files?

2015-05-05 Thread Leonel Câmara
Olá,

I don't really use pygal but I'm guessing something like this would work

Have a function like this in your controller:

def chart():
import pygal
# I just took this from their examples I don't know how to use pygal
bar_chart = pygal.Bar()
bar_chart.title = 'Browser usage evolution (in %)'
bar_chart.x_labels = map(str, range(2002, 2013))
bar_chart.add('Firefox', [None, None, 0, 16.6,   25,   31, 36.4, 45.5, 
46.3, 42.8, 37.1])
bar_chart.add('Chrome',  [None, None, None, None, None, None,0,  3.9
, 10.8, 23.8, 35.3])
bar_chart.add('IE',  [85.8, 84.6, 84.7, 74.5,   66, 58.6, 54.7, 44.8
, 36.2, 26.6, 20.1])
bar_chart.add('Others',  [14.2, 15.4, 15.3,  8.9,9, 10.4,  8.9,  5.8
,  6.7,  6.8,  7.5])
# Now web2py stuff
response.headers['Content-Type'] = 'image/svg+xml'
return bar_chart.render()



Then somewhere in your view:






Does it 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/d/optout.


[web2py] Re: Solve enconding on diferent server

2015-05-05 Thread Leonardo Pires Felix
I think that the problem was that...

I've installed psycopg2 and it dependencies. And worked as expected.

pg8000 has limitation/bug about this?

Em quinta-feira, 30 de abril de 2015 22:39:59 UTC-3, Leonardo Pires Felix 
escreveu:
>
> Hi everyone.
> i have a server that used for all my applications.
> I can save any word on sqlform, "João", "josé", any word with accent.
>
> But one of my clients needed that the server would be hosted on their 
> dependencies. So i copied the folder of my application, and made a dump of 
> database.
>
> Downloaded web2py on the client machine, and installed the application 
> depedencies and restored database. The problem is if any accent letter is 
> on the request. It gives the 'ascii' codec can't decode byte 0xc3 in 
> position 215: ordinal not in range(128)
>
> Any help in what may solve my problem? The database(original, and client) 
> are in utf8, as both locales of the linux distribuitions is pt_br.UTF-8.
>
> Maybe is a problem of change the distribution? On my server is debian 7, 
> and on the client is one distribution called "Linux educacional" that is 
> based on Ubuntu 11.
>

-- 
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: Solve enconding on diferent server

2015-05-05 Thread Leonardo Pires Felix
I can read the accents letters that from the database and they display 
normal.

But if i try to update or insert letter with accent it gives that 
unicodeerror

Em segunda-feira, 4 de maio de 2015 12:56:36 UTC-3, Tom Stratton escreveu:
>
> Hi -
>
> I've had several unicode issues pop up with postgres and pydal in the last 
> couple of weeks - it may be a version issue.
>
> What versions of web2py and pydal are you using, what database adapter, 
> and what - specifically - is giving you the crash?
>
> Is the problem when you try to read from the db or only when you write to 
> it? What is the stack track?
>
> The more info you provide the more likely you are to get help ;-)
>
> Tom
>

-- 
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: Singletons Save Memory and Time

2015-05-05 Thread Dave S


On Tuesday, May 5, 2015 at 4:13:27 PM UTC-7, Joe Barnhart wrote:
>
> I'm doing a lot of web2py programming lately, and much of my time is spent 
> building helper classes that act as "factories" for high-powered web 
> gadgets.  i have a class that builds jQuery DataTables, for example, and 
> another that builds "widgets" as defined in my templating system (each of 
> which is an elaborate construct of header, toolbar, body, etc.).
>
 

> [...]
> Here is a sample of a widget happily sitting on its web page.  It is quick 
> to load and refresh, because (a) it's compiled into a module and (b) it's a 
> singleton!
>
>
> 
>
>

This is an impressive post.  I think I'm going to need to read it a couple 
of times.  Just to make sure I understand what I'm looking at,
the widget in the image has 3 sortable columns in the current tab, and a 
second tab as well?

/dps
 
 

-- 
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] Singletons Save Memory and Time

2015-05-05 Thread Joe Barnhart
I'm doing a lot of web2py programming lately, and much of my time is spent 
building helper classes that act as "factories" for high-powered web 
gadgets.  i have a class that builds jQuery DataTables, for example, and 
another that builds "widgets" as defined in my templating system (each of 
which is an elaborate construct of header, toolbar, body, etc.).

It occurred to me that many of these objects were by nature a "singleton" 
-- that is, a single instance of the object (the factory in this case) 
could be used over and over.  The alternative is to create a new instance 
and initialize it each time you use it -- and since it is used several 
times on each page, that means a lot of instances created and destroyed.

So how do you make something a singleton?  Step Zero is to make sure we are 
building these classes in a "module" instead of a model or a controller. 
 These must be compiled for their magic goodness to work properly. 
 Otherwise, there's no savings of effort, but the opposite!

Step one is to ensure there is nothing in the object's instance vars which 
is unique to that instance.  In other words, anything that changes from one 
use of the object to the next must be passed in from outside.  In my case 
the widgets are all driven from the database, so they don't hold any 
internal state to worry about.

Next, we need to determine how unique these instances are -- is there only 
one?  Is there potentially a different one on each distinct web page 
(controller/function)?  We use this to create a dictionary of instances 
that stores the object we create for each page in between invocations.

Last, we implement a "metaclass" that take care of the lookup of the 
singleton instance, or creates a new one if the singleton dictionary is 
empty.  The metaclass is the cleanest way of creating a Singleton.  There 
are other patterns in Python, but they all suffer from one problem or 
another.  Some replace the class object with a function -- those won't work 
if you subclass anything.  Of the three or four patterns I tried, this is 
the best.

Singleton class definition:

#!/usr/bin/env python
# coding: utf8

from gluon.globals import current

_instances = {}
class Singleton(type):
def __call__(cls, *args, **kwargs):
cr = current.request
key = ('/').join([cr.controller,cr.function])
if key not in _instances:
_instances[key] = super(Singleton, cls).__call__(*args, 
**kwargs)
return _instances[key]


This class keeps a dictionary of instances and uses a key of 
"contoller/function" from the current request to look up the Singleton. 
 Other dictionary keys are useful in other scenarios.  Also note that 
Singleton is a subclass of "type", not "object" as you may expect. 

To make a class (or even a superclass of classes) a Singleton, just declare 
the metaclass like so:


class WidgetHandler(object):
if current.settings.singleton:
__metaclass__ = Singleton

def __init__(self, controller=None, title='', id=None, theme=None ):
from gluon.storage import Storage
from fcn import make_theme
self.controller = controller
self.params = Storage()
self.id = id
self.title = title
self.theme = make_theme(theme)
self.api = ['widget','content']
self.scripts = []
self.html_cache = None
self.script_cache = None
self.init_datatables()


The critical business is highlighted.  just declare this class to use 
"Singleton" as metaclass and it will magically become a Singleton.  I left 
the __init__ showing so you can see how elaborate initialization can be. 
 The call to "init_datatables" creates and initializes a jQuery Datatables 
object that, itself, requires a lot of steps.  It then builds the HTML 
representation of the widget, the javascripts that go with it, and so 
forth.  All of that effort is saved by bypassing this initialization each 
time.

In my case, WidgetHandler is itself used as a superclass by numerous 
WidgetXXX classes.  It holds the common template and reduces the amount of 
code in each widget class.  It also provides a single point of control for 
all of the common code.  Singleton "decorator" patterns do not work when 
creating a superclass because the class name is replaced with a function 
that generates a class, so super() fails to work properly.

Note the use of the global option "current.settings.singleton" to turn the 
Singleton feature off for debugging.  This will save some hair pulling as 
you work on the code, expecting it to use the code you just edited when the 
object has been cached instead!  It also provides an easy way to compare 
speed and memory usage with and without the Singleton feature.


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

Re: [web2py] Re: grid and field_id

2015-05-05 Thread Niphlod


On Tuesday, May 5, 2015 at 9:47:10 PM UTC+2, Massimiliano wrote:
>
>
> I understand but get things screwed as you as saying is a programming 
> error.
>

There are things that are not "foreseen" by developers and web2py generally 
doesn't do lots of typechecking (under the consensum that who approaches 
python is a "consenting adult"). 
Granted, if someone is using a shortcut for its restricted usecase scenario 
and then something breaks, he's not a happy manbut he was indeed using 
a shortcut that would break in the all-usercase-scenarios. 
Something documented as "*field_id must be the field of the table to be 
used as ID*" isn't really prone to interpretations :-P
 

> It also always worked that way and no one complain about it. :-)
>

Nobody used it that way, and the fact that it works has nothing to do with 
web2py code, but a fortunate coincidence on your side


> Was useful, flexible and cheaper. :-D
>

all of the above, with the little side-effect of being unmaintainable as 
soon as a new fix gets pushed in (such as the one you faced, required for a 
strict and correct ordering). same goes for the next enhancement, and for 
new features.

-- 
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: Using Travis CI to test a web2py app on Github

2015-05-05 Thread Niphlod
well, until web2py gets posted on pypi regularly there won't be any magic 
"pip install web2py" to make it work fine. 
That being said customizing a "thing" that fetches web2py from github, 
inserts your app in applications/whatever in the before_script shouldn't be 
THAT hard.

On Tuesday, May 5, 2015 at 10:43:19 PM UTC+2, Ian W. Scott wrote:
>
> I was distracted from this thread, but a belated thanks for your response, 
> Niphlod. To clarify, the error I posted was from Travis CI's remote 
> process. I have no problem running my tests locally, but in that case I can 
> start a web2py instance normally as part of the testing process. The 
> problem on Travis is precisely how to get web2py's libraries in the path. I 
> can't see a way, but I'm not experienced with Travis so I was wondering 
> whether someone else might have more experience. 
>
> By the way, Richard, I think this *is* a relevant (web2py) question for 
> the forum because the question is whether web2py's specific architecture is 
> compatible with a particular (common) testing tool. The answer may be 'no', 
> but I don't think the question is off-topic.
>
>
>
> On Monday, April 13, 2015 at 3:18:56 PM UTC-4, Niphlod wrote:
>>
>> take from the lack of response that if it doesn't run on your machine, 
>> it's not going to run on travis-ci 
>> For starters, it seems that gluon is not importable
>> how do you fetch web2py's libraries and put them into the path ?
>>
>>

-- 
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: web2py-mongodb-engine

2015-05-05 Thread Ron Chatterjee
I was wondering about creating an object inside an object. As shown in the 
link above:


{
  'created_on': ISODate('...'),
  'author' : {
'name': 'Bob',
'email': 'b...@example.org'
  },
  'text' : 'The cake is a lie'}




instead of that dict someone can also write it as:


{
  'created_on': ISODate('...'),
  'author_name' : 'Bob',
   'author_email': 'b...@example.org',
  'text' : 'The cake is a lie'}


Django handles with "EmbeddedModelField". How does web2py handles that? 


On Tuesday, May 5, 2015 at 12:58:48 PM UTC-4, Cássio Botaro wrote:
>
> Actually DAL have experimental mongodb support.
> You can see 
> http://www.web2pyslices.com/slice/show/1580/save-the-earth-from-a-total-data-mess-with-mongodbadapter
>

-- 
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: Using Travis CI to test a web2py app on Github

2015-05-05 Thread Ian W. Scott
I was distracted from this thread, but a belated thanks for your response, 
Niphlod. To clarify, the error I posted was from Travis CI's remote 
process. I have no problem running my tests locally, but in that case I can 
start a web2py instance normally as part of the testing process. The 
problem on Travis is precisely how to get web2py's libraries in the path. I 
can't see a way, but I'm not experienced with Travis so I was wondering 
whether someone else might have more experience. 

By the way, Richard, I think this *is* a relevant (web2py) question for the 
forum because the question is whether web2py's specific architecture is 
compatible with a particular (common) testing tool. The answer may be 'no', 
but I don't think the question is off-topic.



On Monday, April 13, 2015 at 3:18:56 PM UTC-4, Niphlod wrote:
>
> take from the lack of response that if it doesn't run on your machine, 
> it's not going to run on travis-ci 
> For starters, it seems that gluon is not importable
> how do you fetch web2py's libraries and put them into the path ?
>
>

-- 
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: How to add a trailing slash in URL?

2015-05-05 Thread Willoughby
Well then how about a nasty reg-ex in the web server?
Something like this for nginx:
rewrite ^([^\?#]*/)([^\?#\./]+)([\?#].*)?$ $1$2/$3 permanent;

http://www.nginxtips.com/add-trailing-slash-nginx/


On Tuesday, May 5, 2015 at 4:16:57 PM UTC-4, Francisco Costa wrote:
>
> nothing to explain, I just want my URL's to finish with a trail (obviously 
> excluding the ones with vars)
>
> Francisco Tomé Costa
> +351 918412636
> https://www.linkedin.com/in/franciscocosta​
>
> On Tue, May 5, 2015 at 8:46 PM, Willoughby  > wrote:
>
>> Maybe if you explained what problem you're trying to fix.
>>
>>
>> On Tuesday, May 5, 2015 at 3:32:20 PM UTC-4, Francisco Costa wrote:
>>>
>>> I'm not saying changing all the URL's, but if there was an argument on 
>>> the URL()
>>>
>>> Something like this: URL(trailing=True)
>>>
>>> Francisco Tomé Costa
>>> +351 918412636
>>> https://www.linkedin.com/in/franciscocosta​
>>>
>>> On Tue, May 5, 2015 at 8:06 PM, Leonel Câmara  
>>> wrote:
>>>
 What about stylesheets and other files?

 Do you want their URL to be  
 http://www.example.com/application/static/css/styles.css/

 No and it won't work. Because a / denotes a directory.

 I guess you could do this using pattern based URL rewriting, I don't 
 like 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 a topic in the 
 Google Groups "web2py-users" group.
 To unsubscribe from this topic, visit 
 https://groups.google.com/d/topic/web2py/EGJJ6xC4-2w/unsubscribe.
 To unsubscribe from this group and all its topics, send an email to 
 web2py+un...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.

>>>
>>>  -- 
>> 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/EGJJ6xC4-2w/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to 
>> web2py+un...@googlegroups.com .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
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: Custom comparison function with orderby in select()

2015-05-05 Thread Ian W. Scott
A belated thanks, Anthony. I had forgotten about the rows.sort() method.

On Thursday, April 30, 2015 at 5:13:23 PM UTC-4, Anthony wrote:
>
> The sorting via orderby is handled by the database, so you can't use 
> Python code for that, as it must be executed by the database. However, the 
> Rows object has a .sort() method, which does the sorting in Python after 
> the records are returned by the database. See 
> http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#find--exclude--sort
> .
>
> Note, depending on the size of the dataset, sorting in Python might be 
> slower than having the database handle it.
>
> Anthony
>
> On Thursday, April 30, 2015 at 3:42:06 PM UTC-4, Ian W. Scott wrote:
>>
>> I want to sort the results of a select() based on a string field. 
>> Normally I can just use select(orderby=db.mytable.myfield), but the strings 
>> are not in Latin characters, so the default string sorting produces 
>> unacceptable results. 
>>
>> I've figured out how to create a comparison function using the PyICU 
>> bindings to the ICU library. In a regular list sort this allows me to do 
>> something like this:
>>
>> from icu import Locale, Collator
>> myloc = Locale('el')
>> col = Collator.createInstance(myloc) 
>> words = ['ἀγ', 'βλα', 'ὁμηρ']
>> sorted_words = sorted(words, cmp=col.compare) 
>>
>> Is there any way to pass this kind of custom collating function to the 
>> select()?   
>>
>

-- 
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] Two SQLFORMs side by side?

2015-05-05 Thread LoveWeb2py
Hi Richard,

I'm trying to get this setup, but am receiving an error self.url = 
URL(args=request.args)\nNameError: global name \'URL\' is not defined\n'. 
I'm wondering if this is because the gluon hasn't been imported yet.

Also, could you ellaborate more on this?


field=db.table.representing_field,
id_field=db.table.id_field,

id_field should be the foreignkey table if I am not mistaking? 
db.table.representing field, and db.table2.id_field (with foreign key) does 
that sound right?


On Wednesday, April 29, 2015 at 10:04:35 AM UTC-4, Richard wrote:
>
> *# In a modules :*
>
> class AutocompleteWidgetSelectOrAddOption(object):
> _class = 'string'
>
> def __init__(self,
>  request,
>  field,
>  id_field=None,
>  db=None,
>  orderby=None,
>  limitby=(0, 10),
>  keyword='_autocomplete_%(fieldname)s',
>  min_length=2,
>  # 
> -
>  # From : SelectOrAddOption
>  controller=None, function=None, form_title=None,
>  button_text = None, dialog_width=1000,
>  # 
> -
>  placeholder=None
>  ):
> self.request = request
> self.keyword = keyword % dict(fieldname=field.name)
> self.db = db or field._db
> self.orderby = orderby
> self.limitby = limitby
> self.min_length = min_length
> self.fields = [field]
> self.placeholder = placeholder
> if id_field:
> self.is_reference = True
> self.fields.append(id_field)
> else:
> self.is_reference = False
> if hasattr(request, 'application'):
> self.url = URL(args=request.args)
> self.callback()
> else:
> self.url = request
> # 
> --
> # From : SelectOrAddOption
> if form_title is None:
> self.form_title = current.T('Add New')
> else:
> self.form_title = current.T(form_title)
> if button_text is None:
> self.button_text = current.T('Add')
> else:
> self.button_text = current.T(button_text)
> self.dialog_width = dialog_width
>
> self.controller = controller
> self.function = function
> # 
> --
>
> def callback(self):
> if self.keyword in self.request.vars:
> field = self.fields[0]
> rows = self.db(field.like(self.request.vars[self.keyword]+'%')
>).select(orderby=self.orderby, 
> limitby=self.limitby, *self.fields)
> if rows:
> if self.is_reference:
> id_field = self.fields[1]
> raise HTTP(200, SELECT(_id=self.keyword, 
> _class='autocomplete',
>_size=len(rows), 
> _multiple=(len(rows) == 1),
>*[OPTION(s[field.name], 
> _value=s[id_field.name],
> _selected=(k == 0))
>  for k, s in 
> enumerate(rows)]).xml())
> else:
> raise HTTP(200, SELECT(_id=self.keyword, 
> _class='autocomplete',
>_size=len(rows), 
> _multiple=(len(rows) == 1),
>*[OPTION(s[field.name],
> _selected=(k == 0))
>  for k, s in 
> enumerate(rows)]).xml())
> else:
>
> raise HTTP(200, '')
>
> def __call__(self, field, value, **attributes):
> # 
> --
> # From : SelectOrAddOption
> my_select_id = '%s_%s' % (field._tablename, field.name)
> # 'test_ph_eregistry_id' #select_widget.attributes.get('_id', None)
>
> add_args = [my_select_id]
> # create a div that will load the specified controller via ajax
> # form_loader_div = DIV(LOAD(c=self.controller, f=self.function, 
> args=add_args, ajax=True),
> #   _id=my_select_id + "_dialog-form", 
> _title=self.form_title)
> form_loader_div = DIV(DIV(BUTTON('x', _type='button', 
> _class='close',
>  **{'_data-dismiss': 'modal',
> '_aria-hidden': 'true'}),
>   H3(self.form_title

Re: [web2py] Re: How to add a trailing slash in URL?

2015-05-05 Thread Francisco Tomé Costa
nothing to explain, I just want my URL's to finish with a trail (obviously
excluding the ones with vars)

Francisco Tomé Costa
+351 918412636 <+351918412636>
https://www.linkedin.com/in/franciscocosta​

On Tue, May 5, 2015 at 8:46 PM, Willoughby  wrote:

> Maybe if you explained what problem you're trying to fix.
>
>
> On Tuesday, May 5, 2015 at 3:32:20 PM UTC-4, Francisco Costa wrote:
>>
>> I'm not saying changing all the URL's, but if there was an argument on
>> the URL()
>>
>> Something like this: URL(trailing=True)
>>
>> Francisco Tomé Costa
>> +351 918412636
>> https://www.linkedin.com/in/franciscocosta​
>>
>> On Tue, May 5, 2015 at 8:06 PM, Leonel Câmara 
>> wrote:
>>
>>> What about stylesheets and other files?
>>>
>>> Do you want their URL to be
>>> http://www.example.com/application/static/css/styles.css/
>>>
>>> No and it won't work. Because a / denotes a directory.
>>>
>>> I guess you could do this using pattern based URL rewriting, I don't
>>> like 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 a topic in the
>>> Google Groups "web2py-users" group.
>>> To unsubscribe from this topic, visit
>>> https://groups.google.com/d/topic/web2py/EGJJ6xC4-2w/unsubscribe.
>>> To unsubscribe from this group and all its topics, send an email to
>>> web2py+un...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>  --
> 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/EGJJ6xC4-2w/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/d/optout.
>

-- 
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] how to run tests over pydal locally?

2015-05-05 Thread Richard Vézina
https://pytest.org/latest/unittest.html

On Tue, May 5, 2015 at 2:53 PM, Niphlod  wrote:

> given that pretty much all tests are one-liners, I really don't see the
> issue at hand :P
>
> On Tuesday, May 5, 2015 at 3:49:37 PM UTC+2, Richard wrote:
>>
>> :(
>>
>> I find unittest not really more informative then a pointer on which line
>> test failed... In py.test you have an few lines of the scope (let say the
>> function call) that failed... That why I ask the question... If this is not
>> possible for now, too bad.
>>
>> Richard
>>
>> On Mon, May 4, 2015 at 3:20 PM, Niphlod  wrote:
>>
>>> ok, rephrasing: *in order to gain any advantage in using py.test over
>>> unittests* you'd need to rewrite the entire test-suite.
>>>
>>> if you don't rewrite them, nothing of py.test fancy features can be used.
>>>
>>>
>>>
>>> On Monday, May 4, 2015 at 6:16:56 AM UTC+2, Vinicius Assef wrote:

 As far as the py.test docs says, you shouldn’t need to rewrite them.

 py.test understands unittest tests.


 On 3 May 2015, at 09:17, Niphlod  wrote:

 you need to rewrite the entire test-suite.

 On Thursday, April 30, 2015 at 8:46:38 PM UTC+2, Richard wrote:
>
> Simone,
>
> How can I run unittest with py.test?
>
> Richard
>
> On Wed, Apr 29, 2015 at 4:38 PM, Richard Vézina  > wrote:
>
>> my bad from not form...
>>
>> :(
>>
>> Richard
>>
>> On Wed, Apr 29, 2015 at 4:34 PM, Richard Vézina <
>> ml.richa...@gmail.com> wrote:
>>
>>> that's how validators.py is added!!
>>>
>>> I don't find how to import smart_query
>>>
>>> from pydal.helpers.methods import smart_query
>>>
>>> the above returns "invalid syntax"
>>>
>>> Richard
>>>
>>> On Wed, Apr 29, 2015 at 4:28 PM, Niphlod  wrote:
>>>
 oh my. Add to __init__ ^_^'

 On Wednesday, April 29, 2015 at 10:18:51 PM UTC+2, Richard wrote:
>
> One more I don't see my news tests executing...
>
> Is there anything else to do then add an new file of unitttest
> into pydal/tests
>
> To add news cases?
>
> Richard
>
> On Wed, Apr 29, 2015 at 4:13 PM, Richard Vézina <
> ml.richa...@gmail.com> wrote:
>
>> :)
>>
>> I don't test enough!!
>>
>> Richard
>>
>> On Wed, Apr 29, 2015 at 4:08 PM, Niphlod 
>> wrote:
>>
>>> some time I just don't know what's going on with my writing. Am
>>> I really that obscure ?
>>>
>>> can you spot the difference from mine
>>>
>>> *python -m unittest -v tests*
>>>
>>> and yours
>>>
>>> *python -m unittest -v validation.py*
>>>
>>> ?
>>>
>>> To be more precise (and abnoxious, maybe). Place yourself in the
>>> root dir of pydal. then copy
>>>
>>> *python -m unittest -v tests*
>>>
>>> and paste to your commandline. Then press enter.
>>>
>>>
>>> --
>>> 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+un...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>
 --
 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+un...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.

>>>
>>>
>>
>
 --
 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+un...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.


  --
>>> Resources:
>>> - http://web2py.com
>>> - http://we

Re: [web2py] Re: grid and field_id

2015-05-05 Thread Massimiliano
I understand but get things screwed as you as saying is a programming error.

It also always worked that way and no one complain about it. :-)

Was useful, flexible and cheaper. :-D



On Tue, May 5, 2015 at 8:48 PM, Niphlod  wrote:

> as you're explaining it, you were using it wrongly.
> field_id needs to be a field that comes from either the table you're
> passing OR a field from a table that gets included when you pass a set, or
> everything gets screwed: details, selectable, view, edit, etc use the
> field_id to identify the record : it can't come from another table, even if
> your view is calling it under the hood (but web2py doesn't know 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/d/optout.
>



-- 
Massimiliano

-- 
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: How to add a trailing slash in URL?

2015-05-05 Thread Willoughby
Maybe if you explained what problem you're trying to fix.


On Tuesday, May 5, 2015 at 3:32:20 PM UTC-4, Francisco Costa wrote:
>
> I'm not saying changing all the URL's, but if there was an argument on the 
> URL()
>
> Something like this: URL(trailing=True)
>
> Francisco Tomé Costa
> +351 918412636
> https://www.linkedin.com/in/franciscocosta​
>
> On Tue, May 5, 2015 at 8:06 PM, Leonel Câmara  > wrote:
>
>> What about stylesheets and other files?
>>
>> Do you want their URL to be  
>> http://www.example.com/application/static/css/styles.css/
>>
>> No and it won't work. Because a / denotes a directory.
>>
>> I guess you could do this using pattern based URL rewriting, I don't like 
>> 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 a topic in the 
>> Google Groups "web2py-users" group.
>> To unsubscribe from this topic, visit 
>> https://groups.google.com/d/topic/web2py/EGJJ6xC4-2w/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to 
>> web2py+un...@googlegroups.com .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
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: How to add a trailing slash in URL?

2015-05-05 Thread Francisco Tomé Costa
I'm not saying changing all the URL's, but if there was an argument on the
URL()

Something like this: URL(trailing=True)

Francisco Tomé Costa
+351 918412636 <+351918412636>
https://www.linkedin.com/in/franciscocosta​

On Tue, May 5, 2015 at 8:06 PM, Leonel Câmara 
wrote:

> What about stylesheets and other files?
>
> Do you want their URL to be
> http://www.example.com/application/static/css/styles.css/
>
> No and it won't work. Because a / denotes a directory.
>
> I guess you could do this using pattern based URL rewriting, I don't like
> 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 a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/web2py/EGJJ6xC4-2w/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/d/optout.
>

-- 
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: How to add a trailing slash in URL?

2015-05-05 Thread Leonel Câmara
What about stylesheets and other files?

Do you want their URL to be 
 http://www.example.com/application/static/css/styles.css/

No and it won't work. Because a / denotes a directory.

I guess you could do this using pattern based URL rewriting, I don't like 
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/d/optout.


Re: [web2py] how to run tests over pydal locally?

2015-05-05 Thread Niphlod
given that pretty much all tests are one-liners, I really don't see the 
issue at hand :P

On Tuesday, May 5, 2015 at 3:49:37 PM UTC+2, Richard wrote:
>
> :(
>
> I find unittest not really more informative then a pointer on which line 
> test failed... In py.test you have an few lines of the scope (let say the 
> function call) that failed... That why I ask the question... If this is not 
> possible for now, too bad.
>
> Richard
>
> On Mon, May 4, 2015 at 3:20 PM, Niphlod > 
> wrote:
>
>> ok, rephrasing: *in order to gain any advantage in using py.test over 
>> unittests* you'd need to rewrite the entire test-suite. 
>>
>> if you don't rewrite them, nothing of py.test fancy features can be used.
>>
>>
>>
>> On Monday, May 4, 2015 at 6:16:56 AM UTC+2, Vinicius Assef wrote:
>>>
>>> As far as the py.test docs says, you shouldn’t need to rewrite them.
>>>
>>> py.test understands unittest tests.
>>>
>>>
>>> On 3 May 2015, at 09:17, Niphlod  wrote:
>>>
>>> you need to rewrite the entire test-suite.
>>>
>>> On Thursday, April 30, 2015 at 8:46:38 PM UTC+2, Richard wrote:

 Simone,

 How can I run unittest with py.test?

 Richard

 On Wed, Apr 29, 2015 at 4:38 PM, Richard Vézina  
 wrote:

> my bad from not form...
>
> :(
>
> Richard
>
> On Wed, Apr 29, 2015 at 4:34 PM, Richard Vézina  > wrote:
>
>> that's how validators.py is added!!
>>
>> I don't find how to import smart_query
>>
>> from pydal.helpers.methods import smart_query
>>
>> the above returns "invalid syntax"
>>
>> Richard
>>
>> On Wed, Apr 29, 2015 at 4:28 PM, Niphlod  wrote:
>>
>>> oh my. Add to __init__ ^_^'
>>>
>>> On Wednesday, April 29, 2015 at 10:18:51 PM UTC+2, Richard wrote:

 One more I don't see my news tests executing...

 Is there anything else to do then add an new file of unitttest into 
 pydal/tests

 To add news cases?

 Richard

 On Wed, Apr 29, 2015 at 4:13 PM, Richard Vézina <
 ml.richa...@gmail.com> wrote:

> :)
>
> I don't test enough!!
>
> Richard
>
> On Wed, Apr 29, 2015 at 4:08 PM, Niphlod  wrote:
>
>> some time I just don't know what's going on with my writing. Am I 
>> really that obscure ?
>>
>> can you spot the difference from mine
>>
>> *python -m unittest -v tests*
>>
>> and yours
>>
>> *python -m unittest -v validation.py*
>>
>> ?
>>
>> To be more precise (and abnoxious, maybe). Place yourself in the 
>> root dir of pydal. then copy 
>>
>> *python -m unittest -v tests*
>>
>> and paste to your commandline. Then press enter. 
>>
>>
>> -- 
>> 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+un...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

>>> -- 
>>> 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+un...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>

>>> -- 
>>> 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+un...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>>
>>>  -- 
>> 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.
>> 

[web2py] Re: Is it possible to create a webservice funcion for login (instead of basic authentication)?

2015-05-05 Thread Niphlod
usually services do not make use of session cookies, that are the ones 
web2py checks. A service should use something like basic authentication...

On Tuesday, May 5, 2015 at 6:57:23 PM UTC+2, Lisandro wrote:
>
> I'm creating a XMLRPC webservice with web2py, everything works perfect. 
> In order to restrict access to the webservice, acordingly to the docs, you 
> have to decorate the function that instantiates the webservice, for example:
>
> @auth.requires_login()
> def call():
> return service()
>
>
> @service.xmlrpc
> def check():
> return auth.user.email
>
> So, in order to connect to this webservice, you would have to pass the 
> user and password in the url, like this:
> http://user:email@domain/default/call/xmlrpc
> And then you would be able to run the function "check()" of the webservice.
>
> So far all good. But what if I want to create a public webservice, and 
> include a function for login (taking user and email as arguments)? The 
> function should login the user and next calls to other functions should be 
> able to check if user is logged in.
>
> I've tried this with no success:
>
> def call():
> return service()
>
>
> @service.xmlrpc
> def login(data):
> user = auth.login_bare(data['email'], data['password'])
> if not user:
> return False
> else:
> auth.login_user(user)
> return True
>
>
> @service.xmlrpc
> def check():
> if auth.is_logged_in():
> return auth.user.email
> else:
> return False
>
> However this doesn't work. I can succesfully connect to the webservice, 
> and I can succesfully execute "login()" function, but then inmediately I 
> execute "check()" function and I always receive False, so the session isn't 
> created.
>
> For the testing client I'm using class ServerProxy from python xmlrpclib. 
> I know this is easy to fix (using the first of the two examples shown 
> here), but not all clients support basic authentication and I'm trying to 
> figure out what to do for those cases. Thanks in advance!
>

-- 
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: grid and field_id

2015-05-05 Thread Niphlod
as you're explaining it, you were using it wrongly. 
field_id needs to be a field that comes from either the table you're 
passing OR a field from a table that gets included when you pass a set, or 
everything gets screwed: details, selectable, view, edit, etc use the 
field_id to identify the record : it can't come from another table, even if 
your view is calling it under the hood (but web2py doesn't know 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/d/optout.


Re: [web2py] Re: How to add a trailing slash in URL?

2015-05-05 Thread Francisco Tomé Costa
My idea was to only add the trailing slash to the last argument (if any) or
function.

URLs with vars would look like this:
http://www.example.com/application/controller/function/?foo=bar

Francisco Tomé Costa
+351 918412636 <+351918412636>
https://www.linkedin.com/in/franciscocosta​

On Tue, May 5, 2015 at 6:39 PM, Leonel Câmara 
wrote:

> Why? This is a bad idea what about URLs that have vars?
>
> --
> 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/EGJJ6xC4-2w/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/d/optout.
>

-- 
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: grid and field_id

2015-05-05 Thread Massimiliano
Sorry my english is very poor and probably I described the problem in a bad
manner.

In my database I have a table and a view of that table.
Lets call them:

mytable
view_mytable

view_mytable is a db view. Defined as:

CREATE OR REPLACE VIEW view_mytable AS
 SELECT
   mytable.*
   'myvalues' as other_field
 FROM
   mytable;


I define them in web2py:

db.define_table('mytable',Field('myfield'))
db.define_table('view_mytable',Field('myfield'),Field('other_field'))

with old web2py (2.9.5) I was able to do:

SQLFORM.grid(db.view_mytable, field_id=db.mytable.id)

and the grid showed all fields of db.view_mytable in the tabular data but
when editing, the grid allowed to me to edit directly db.mytable because
of: field_id=db.mytable.id

Now this behaviour, that I find useful, mainly to work on legacy databases
has changed.

But I found the solution while I was writing this reply.

SQLFORM.grid(db.view_mytable, field_id=db.mytable.id,
*auto_pagination=False*)

But pagination has nothing to do with my intent.
So I don't know if this way to proceed is/was/wannabe supported or not but
could save a lot of work.

Maybe the place to discuss of it is in github issue.

Thank you


On Tue, May 5, 2015 at 6:18 PM, Cássio Botaro 
wrote:

> I try to reproduce in 2.10.4 and i have two errors:
>
> first - Field('myfield) should be Field('myfield'), but i think it is
> only a typo.
> second -  SQLFORM.grid(db.myview, field_id=db.mytable.id) should be  
> SQLFORM.grid(db.myview,
> field_id=db.view.id )
>
> No more errors at all.
>
> No problems with orderby.
>
>
>
>  --
> 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.
>



-- 
Massimiliano

-- 
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: How to add a trailing slash in URL?

2015-05-05 Thread Leonel Câmara
Why? This is a bad idea what about URLs that have vars?

-- 
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: web2py-mongodb-engine

2015-05-05 Thread Cássio Botaro
Actually DAL have experimental mongodb support.
You can 
see 
http://www.web2pyslices.com/slice/show/1580/save-the-earth-from-a-total-data-mess-with-mongodbadapter

-- 
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] Is it possible to create a webservice funcion for login (instead of basic authentication)?

2015-05-05 Thread Lisandro
I'm creating a XMLRPC webservice with web2py, everything works perfect. 
In order to restrict access to the webservice, acordingly to the docs, you 
have to decorate the function that instantiates the webservice, for example:

@auth.requires_login()
def call():
return service()


@service.xmlrpc
def check():
return auth.user.email

So, in order to connect to this webservice, you would have to pass the user 
and password in the url, like this:
http://user:email@domain/default/call/xmlrpc
And then you would be able to run the function "check()" of the webservice.

So far all good. But what if I want to create a public webservice, and 
include a function for login (taking user and email as arguments)? The 
function should login the user and next calls to other functions should be 
able to check if user is logged in.

I've tried this with no success:

def call():
return service()


@service.xmlrpc
def login(data):
user = auth.login_bare(data['email'], data['password'])
if not user:
return False
else:
auth.login_user(user)
return True


@service.xmlrpc
def check():
if auth.is_logged_in():
return auth.user.email
else:
return False

However this doesn't work. I can succesfully connect to the webservice, and 
I can succesfully execute "login()" function, but then inmediately I 
execute "check()" function and I always receive False, so the session isn't 
created.

For the testing client I'm using class ServerProxy from python xmlrpclib. 
I know this is easy to fix (using the first of the two examples shown 
here), but not all clients support basic authentication and I'm trying to 
figure out what to do for those cases. Thanks in advance!

-- 
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] web2py-mongodb-engine

2015-05-05 Thread Ron Chatterjee
Is there a tutorial similar to this exist anywhere that anyone know off? In 
otherwords, do we have have web2py-mongodb engine that we can use the 
embedded model?

http://django-mongodb-engine.readthedocs.org/en/latest/tutorial.html#embedded-models

I believe the "view" in django is similar to models in web2py. 



-- 
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: Sublime Text web2py plugin

2015-05-05 Thread Cássio Botaro
Nice!

I will test and update 
my_enviroment(https://github.com/cassiobotaro/my_environment 
)

Thanks to share.

-- 
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] How to add a trailing slash in URL?

2015-05-05 Thread Francisco Costa

Is there any way to force URL to add a trailing slash?
Even if there are any vars (query strings) I would like the last argument 
(or function) to have a trailing slash.

-- 
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: grid and field_id

2015-05-05 Thread Cássio Botaro
I try to reproduce in 2.10.4 and i have two errors:

first - Field('myfield) should be Field('myfield'), but i think it is only 
a typo.
second -  SQLFORM.grid(db.myview, field_id=db.mytable.id) should be  
SQLFORM.grid(db.myview, 
field_id=db.view.id )

No more errors at all.

No problems with orderby.



-- 
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: what is syntax for including "writable = false" right in the table definition?

2015-05-05 Thread Alex Glaros
great, thanks Anthony

one step closer to w2p Nirvana

-- 
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] D3.js DC.js Crossfilter.js - table not showing

2015-05-05 Thread António Ramos
2014-05-20 10:19 GMT+01:00 thehuman trashcan :

> URL('views', 'default/dashboard_data.json')


the URL('views', 'default/dashboard_data.json') is valid ?
pasting just the corresponding url in the browsers returns your data?
try
console.log(data) before

var dtgFormat = d3.time.format("%d/%m/%Y");
and see in the browser console if you see your data...

-- 
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] grid and field_id

2015-05-05 Thread Richard Vézina
It surely not going to be fix in 2.9.5... Do you check in new version of
web2py if this issue is still relevant? If so consider open a ticket and
maybe make a PR so others can review it.

Richard

On Tue, May 5, 2015 at 9:09 AM, Massimiliano  wrote:

> Hi,
>
> in web2py 2.9.5 and older I was using database views to simplify my work
> doing  something like that:
>
>   db.define_table('mytable',Field('myfield))
>
> having a view on my db with all mytable fields plus some others.
>
> I define the view in web2py:
>
>   db.define_table('myview',Field('myfield), Field('otherfield'))
>
> So I was using the grid in this way:
>
>   SQLFORM.grid(db.myview, field_id=db.mytable.id)
>
> and worked like a charm showing the view in the grid and editing mytable
> in add/edit/delete
>
> Now doesn't work anymore cause this line of code:
>
>   orderby = fix_orderby(orderby) in sqlhtml.py line 2561 (2.10.4)
>
> but a simple:
>
>   if not orderby:
>  orderby = fix_orderby(orderby)
>
> fix the problem.
>
> I don't know if this way to proceed is/was supported or not but could save
> a lot of work.
>
> Can we restore the older behaviour?
>
> What do you think?
>
> Thank you
> --
> Massimiliano
>
> --
> 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.
>

-- 
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] how to run tests over pydal locally?

2015-05-05 Thread Richard Vézina
:(

I find unittest not really more informative then a pointer on which line
test failed... In py.test you have an few lines of the scope (let say the
function call) that failed... That why I ask the question... If this is not
possible for now, too bad.

Richard

On Mon, May 4, 2015 at 3:20 PM, Niphlod  wrote:

> ok, rephrasing: *in order to gain any advantage in using py.test over
> unittests* you'd need to rewrite the entire test-suite.
>
> if you don't rewrite them, nothing of py.test fancy features can be used.
>
>
>
> On Monday, May 4, 2015 at 6:16:56 AM UTC+2, Vinicius Assef wrote:
>>
>> As far as the py.test docs says, you shouldn’t need to rewrite them.
>>
>> py.test understands unittest tests.
>>
>>
>> On 3 May 2015, at 09:17, Niphlod  wrote:
>>
>> you need to rewrite the entire test-suite.
>>
>> On Thursday, April 30, 2015 at 8:46:38 PM UTC+2, Richard wrote:
>>>
>>> Simone,
>>>
>>> How can I run unittest with py.test?
>>>
>>> Richard
>>>
>>> On Wed, Apr 29, 2015 at 4:38 PM, Richard Vézina 
>>> wrote:
>>>
 my bad from not form...

 :(

 Richard

 On Wed, Apr 29, 2015 at 4:34 PM, Richard Vézina 
 wrote:

> that's how validators.py is added!!
>
> I don't find how to import smart_query
>
> from pydal.helpers.methods import smart_query
>
> the above returns "invalid syntax"
>
> Richard
>
> On Wed, Apr 29, 2015 at 4:28 PM, Niphlod  wrote:
>
>> oh my. Add to __init__ ^_^'
>>
>> On Wednesday, April 29, 2015 at 10:18:51 PM UTC+2, Richard wrote:
>>>
>>> One more I don't see my news tests executing...
>>>
>>> Is there anything else to do then add an new file of unitttest into
>>> pydal/tests
>>>
>>> To add news cases?
>>>
>>> Richard
>>>
>>> On Wed, Apr 29, 2015 at 4:13 PM, Richard Vézina <
>>> ml.richa...@gmail.com> wrote:
>>>
 :)

 I don't test enough!!

 Richard

 On Wed, Apr 29, 2015 at 4:08 PM, Niphlod  wrote:

> some time I just don't know what's going on with my writing. Am I
> really that obscure ?
>
> can you spot the difference from mine
>
> *python -m unittest -v tests*
>
> and yours
>
> *python -m unittest -v validation.py*
>
> ?
>
> To be more precise (and abnoxious, maybe). Place yourself in the
> root dir of pydal. then copy
>
> *python -m unittest -v tests*
>
> and paste to your commandline. Then press enter.
>
>
> --
> 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+un...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>


>>>
>> --
>> 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+un...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

>>>
>> --
>> 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+un...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>>
>>  --
> 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.
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/

[web2py] grid and field_id

2015-05-05 Thread Massimiliano
Hi,

in web2py 2.9.5 and older I was using database views to simplify my work
doing  something like that:

  db.define_table('mytable',Field('myfield))

having a view on my db with all mytable fields plus some others.

I define the view in web2py:

  db.define_table('myview',Field('myfield), Field('otherfield'))

So I was using the grid in this way:

  SQLFORM.grid(db.myview, field_id=db.mytable.id)

and worked like a charm showing the view in the grid and editing mytable in
add/edit/delete

Now doesn't work anymore cause this line of code:

  orderby = fix_orderby(orderby) in sqlhtml.py line 2561 (2.10.4)

but a simple:

  if not orderby:
 orderby = fix_orderby(orderby)

fix the problem.

I don't know if this way to proceed is/was supported or not but could save
a lot of work.

Can we restore the older behaviour?

What do you think?

Thank you
-- 
Massimiliano

-- 
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-05 Thread António Ramos
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

thank u

2015-05-05 7:43 GMT+01:00 Gergely Orosz :

> Thank you Massimo,
>
> I am going to improve it continuously
>
> 2015. május 4., hétfő 18:24:34 UTC+2 időpontban Massimo Di Pierro a
> következőt írta:
>>
>> Nice. Thank you! I added link form the web2py examples/ app.
>>
>> On Monday, 4 May 2015 05:28:55 UTC-5, Gergely Orosz wrote:
>>>
>>> Hi 4 All,
>>>
>>> I've started to develop a web2py plugin for Sublime Text 3.
>>> I've implemented a few command I found very useful on my daily work.
>>> If you have any idea how can I make it better and useful please visit
>>> the below link and submit your feature request there
>>> Thanks in advance
>>>
>>> You can find the plugin: https://bitbucket.org/kfog/w2p
>>>
>>> If you have any question please feel free to ask here or on the Issue
>>> tracker
>>>
>>> All the best
>>> Greg
>>>
>>  --
> 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.
>

-- 
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] Init Script in Web2Py

2015-05-05 Thread Massimiliano
Maybe you can use:

cache.ram.clear('init')

after executing arbitrary_function()

On Tue, May 5, 2015 at 3:56 AM, A36_Marty  wrote:

> Likewise, I too am confused by Massimo's suggestion of using:
>
> if cache.ram('init',lambda:db(db.auth_user).isempty(),None):
>arbitrary_function()
>
>
> The True value indicating auth_user is empty is stored in the cache.ram
> 'init' value, then never updated.   In my test code, 'arbitary_function'
> gets executed every time a page is loaded (since True for .isempty() is
> cached), even after records are added to auth_user
>
> It's only after I stop web2py, restart (and the new value is stored in
> cache.ram 'init' does the function stop being executed.
>
> How can setting a cache.ram value then setting the expiration of the value
> to None / never expire every work?
>
>
>
>
>
> On Monday, March 31, 2014 at 2:57:00 PM UTC-5, Jay Martin wrote:
>>
>> I'm confused as to why this scenario needs caching.
>>
>> Isn't it true that for an empty user table:
>>
>> if cache.ram('init',lambda:db(db.auth_user).isempty(),None):
>>arbitrary_function()
>>
>> will only cache the boolean value True and keep that value (True) in
>> cache forever (until the app is restarted), associated with the given key
>> 'init'?
>>
>> Therefore, only this initial state is remembered. All future executions
>> of this code will only ever return this initial value (True), therefore the
>> subsequent arbitrary function will continue to be executed every cycle of
>> execution.
>>
>> Am I missing something? Many thanks!
>>
>>
>>
>> On Friday, August 10, 2012 11:23:56 PM UTC-4, Massimo Di Pierro wrote:
>>>
>>> you stil want to cache that
>>>
>>> if cache.ram('init',lambda:db(db.mytable).isempty(),None):
>>>
>>>
>>>  --
> 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.
>



-- 
Massimiliano

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