[web2py] Why would this happen?

2012-06-02 Thread Bruce Wade
http://127.0.0.1:8000/yaw/en/static/documents/adspaces.js?attachement
allows me to download the js file
http://127.0.0.1:8000/yaw/en/static/documents/�[得世界网广告服务协议.pdf?attachement
gives me "Invalid Request" both files exist.

Basically I have some files in static/documents I want to allow to be
downloaded. What is the correct way to accomplish this?

-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.fittraineronline.com - Fitness Personal Trainers Online
http://www.warplydesigned.com


[web2py] Re: Regex problem in custom validator

2012-06-02 Thread Cédric Mayer
Can you give us some examples ?

Le vendredi 1 juin 2012 17:49:02 UTC+2, monotasker a écrit :
>
> I have a db field that holds a regular expression (one unique regex for 
> each row in the table). Another row in the table 
> (db.steps.readable_response) lists sample strings that should satisfy the 
> regex. I'm trying to create a custom validator that tests the regular 
> expression against the sample strings at form submission, to highlight 
> problems in the regex before it's submitted. But at the moment the 
> re.match() is failing even when I'm positive it should pass (I've tested 
> them several times using Kiki). Here's the validator class.
>
> class IS_VALID_REGEX(object):
> """
> custom validator to check regex in step definitions against the given
> readable responses.
> """
> def __init__(self):
> self.error_message='Given answers do not satisfy regular 
> expression.'
>
>
> def __call__(self, value):
> request = current.request
> answers = request.vars.readable_response
> alist = answers.split('|')
> value = value.encode('UTF-8')
> regex = value.encode('string-escape')
> for a in alist:
> if re.match(a.strip(), regex, re.I):
> print a.strip()
> print 'it matched!'
> else:
> print 'answer ', a, ' did not match the regular 
> expression provided.'
> print regex
> return (value, self.error_message)
> return (value, None)
>
> The print output show that the correct regex and sample strings are being 
> evaluated. So why is it not passing? 
>
> To complicate things a bit, the regex and sample string both include 
> unicode characters (polytonic Greek). But elsewhere in the app this doesn't 
> seem to have created problems when performing a similar re.match().
>
> Thanks,
>
> Ian
>


[web2py] Re: Trouble migrating databases

2012-06-02 Thread david.waldrop
Massimo,  I started again this morning as I will ultimately need to solve 
this, but am still having issues.  As I enhance the FEMA application I will 
need to move between the production environment and the dev environment 
without loosing data.  This has worked flawlessly for me in the past, but I 
must be doing something wrong now.  

Production environment = Webfaction, Apache, Postgress, web2py 1.99.4
Development machine = Windows, Rocket, sqlite, web2py 2.0.0


Here is what I did:

1. On production I packaged and downloaded the working application
2. I installed via the admin interface on my dev machine
3. I added the migrate_enabled to the DAL (db = 
DAL('sqlite://storage.sqlite', migrate_enabled=True)  )
4. When i run I get the error below and web2py hangs

Error:

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.

Traceback (most recent call last):
  File "gluon/restricted.py", line 205, in restricted
  File "C:/Users/david/My 
Projects/Miscelaneous/web2py/applications/COPSIS/models/db.py" 
, line 47, in 

  File "gluon/tools.py", line 1397, in define_tables
  File "gluon/dal.py", line 6694, in define_table
  File "gluon/dal.py", line 785, in create_table
  File "gluon/dal.py", line 1465, in create_sequence_and_triggers
  File "gluon/dal.py", line 1477, in execute
  File "gluon/dal.py", line 1471, in log_execute
OperationalError: table auth_user already exists



I then tried to delete everything in the databases directory and reran the 
app.  I was unable to delete the log file.  a new sqllite database was 
created, but no table files and web2py hung again.

I killed web2py.  was successful at deleting everything in the web2py and 
the application worked.  

I then tried copying the sqlite dataase file from production to preserve 
some of the original data and am back to having "Operational Error: no such 
column" invite. message"

AM I doing something wrong or has something changed in the past 2-3 months?



On Friday, June 1, 2012 11:31:17 PM UTC-4, Massimo Di Pierro wrote:
>
> Hello David,
>
> Do you have a backup of the databases/ folder that worked with a previous 
> version?
>
> If so..., delete everything in databases. Than do:
>
> db = DAL('sqlite://storage.sqlite', migrate_enabled=True)
>
> Do you get an error? If you do not get any error, check which table files 
> different from the backup and newly created ones. Which version are you 
> upgrading from?
>
>
> massimo
>
>
>
>
> On Friday, 1 June 2012 20:20:03 UTC-5, david.waldrop wrote:
>>
>> I just downloaded the nightly build form Trunk to test the new web2py 2.0 
>> with some of my web2py based solutions.  I now have a very weird eroor I 
>> think due to migrating the database form postgress (production) to sqllite 
>> (development).  Here is one of the errors I get:
>>
>> Traceback (most recent call last):
>>
>>  
>
>>   File "gluon/restricted.py", line 205, in restricted
>>   File "C:/Users/david/My 
>> Projects/Miscelaneous/web2py/applications/COPSIS/controllers/items.py" 
>> , line 
>> 776, in 
>>   File "gluon/globals.py", line 175, in 
>>   File "gluon/tools.py", line 2679, in f
>>   File "C:/Users/david/My 
>> Projects/Miscelaneous/web2py/applications/COPSIS/controllers/items.py" 
>> , line 
>> 20, in additem
>>   File "gluon/sqlhtml.py", line 1298, in accepts
>>   File "gluon/dal.py", line 7255, in insert
>>   File "gluon/dal.py", line 1009, in insert
>> OperationalError: table item has no column named name
>>
>>
>> I have tried several of the migration options, but none seem to work thus 
>> far.
>>
>> Here is the code in db.py I tried after searching the google group:
>>
>> db = DAL('sqlite://storage.sqlite', migrate_enabled=True, 
>> fake_migrate_all=True)
>>
>>
>> When I look in the application/database subdirectory there are not .table 
>> files for each table, which does not seem correct.
>>
>>
>> Any Ideas or suggestions would be greatly appreciated.
>>
>>
>>
>>
>>
>>
On Friday, June 1, 2012 11:31:17 PM UTC-4, Massimo Di Pierro wrote:
>
> Hello David,
>
> Do you have a backup of the databases/ folder that worked with a previous 
> version?
>
> If so..., delete everything in databases. Than do:
>
> db = DAL('sqlite://storage.sqlite', migrate_enabled=True)
>
> Do you get an error? If you do not get any error, check which table files 
> different from the backup and newly created ones. Which version are you 
> upgrading from?
>
>
> massimo
>
>
>
>
> On Friday, 1 June 2012 20:20:03 UTC-5, david.waldrop wrote:
>>
>> I just downloaded the nightly build form Trunk to test the new web2py 2.0 
>> with some of my web2py based solutions.  I now have a very weird eroor I 
>> think due to migrating the database form postgress (production) to sqllite 
>> (development).  Here is one of the errors I get:
>>
>> Traceback (most recent call last)

[web2py] Invalid Circual Reference - misleading error message

2012-06-02 Thread François Delpierre
Hi,

I'm getting (again) stuck with an "Invalid Circual Reference" using Wizard. 
Finally, it looks like I have been able to fix it by just changing the 
order of the table in my wizard, so the table order counts in the wizard. 
We must have listed first all the tables to which we want to refer in the 
table we are defining.


   - The error message should really be adapted in this case, and point to 
   the line where the field is referencing a "non yet fully defined table".
   - We must be able to reorder tables, especially when using the "Edit 
   All" button in the Wizard.


Regards,


[web2py] Time Field

2012-06-02 Thread villas
Does anyone know a good way to exclude seconds when displaying and working 
with time fields?

I looked at IS_TIME but it still doesn't have a formatter and I'm not sure 
how to do it.  However,  I guess there aren't many ways to format the 
time,  so just having the seconds optional would be good.  Maybe we could 
have something like:  IS_TIME(showseconds=True)

Regards,  David


[web2py] Date Types

2012-06-02 Thread villas

I notice that:
form.vars.date_field == str
form.vars.time_field == datetime.time
form.vars.datetime_field == datetime.datetime

Maybe it's just an anomally?  I seem to lose a lot of time getting date and 
time fields from one format to another.  I wonder whether there is a good 
resource anywhere which explains how to convert, add and subtract them etc?


[web2py] Re: using ajax and load for modular applications

2012-06-02 Thread angle
Thanks for your comments. I'll answer each one below, along with the answer 
to Andrew's question in a seperate message.
+ Full code, and results of view page source (for successful opening page) 
are attached.


On Friday, June 1, 2012 8:01:02 PM UTC+1, Anthony wrote:
>
> On Friday, June 1, 2012 2:03:23 PM UTC-4, angle wrote:
>>
>> Thanks for your response, I've answered your points below:  
>>
>>>  
>>>
>>   #response.ajax = \ 
 'web2py_component("%s","patient",ajax=True,vars=vars1)' % URL 
 ('patient')
>>>
>>> I think this should be response.js rather than response.ajax. 
>>>
>>
>> This code is copied from the example 'Designing Modular Applications' on 
>> page 94 of the web2py book.
>>
>
> Unfortunately, I think there are a number of errors in that example, one 
> of which is that it should be response.js, not response.ajax.
>

OK thanks, I'll keep it as response.js. 

 
>
>>   In that example it is called when a forms 'onaccept' event is 
>> triggered. In my code it is called in my 'viewPatient' function that is 
>> called by setting the webGrid's crud_function... (grid.crud_function = 
>> 'viewPatient'). I thought that these were similar calls, so that 
>> response.ajax should work in the same way. Are they not the same? ???
>>
>
> In the book example, response.ajax (which should be response.js) is set in 
> the edit_items() function, which is always called as an Ajax component. You 
> are setting it in your view() function, but I can't see where that function 
> is actually called, so I don't know if it is being called as an Ajax 
> component or as a regular web page.
>

[[NB: To avoid confusion, in the code (included below) I've updated this 
function name to be viewPatient().]]  
This viewPatient() function is set as the webGrid.crud_function property, 
within my index() function of default.py 
(grid.crud_function = 'viewPatient'). I believe the answer to your question 
is that it is called as a regular webpage, 
as webGrid is not an ajax component. 

>   
>
>> Also, response.js is only used if the action that sets it is being called 
>>> as a web2py component -- is that the case here? 
>>>
>>  
>> I believe so, but I am not 100% sure. It appears that the response.ajax 
>> is being set via a call to 'web2py_component(...)' . Is that correct?
>>
>
> No, you are setting response.ajax to "web2py_component(...)" -- that's not 
> what I'm talking about. The question is whether the function in which 
> response.js is being set is itself being accessed by a call to 
> web2py_component() on the client side. It is being set in your view() 
> function, so the question is how is the view() function being called?
>

See last answer above. Sorry about the confusion.

>
> Finally, web2py_component() does not take an ajax or vars argument. If you 
>>> want vars included in the URL, then pass it to the URL function.
>>>
>>
>> The URL is pointing to a div element -  (as in the example from the book).
>>
>
> I think there is an error in the book -- it mistakenly builds a URL that 
> refers to a div id rather than the name of the controller function. Is that 
> what you're talking about?
>

Yes. Since reading your comments, and looking at the page-source for the 
(successful) initial index page upload, I've updated this to:

response.js = \
  
'web2py_component("/ICC_Data_Management/default/post.load?scanId=4","patient");'
 
\
  % URL('/ICC_Data_Management/default/post.load?scanId=4') 

... and this returns the error:   ' not 
enough information to build the url'



>
>
>
+ to answer the question from Andrew, in a seperate message: 
---'Also, I don't see a div with an Id = patient.  That's your target.   Is 
it in the code but not in your post?'

>From the example in the book, it appears (to me) to imply that the 
'{{=LOAD('default', 'list_items', ajax=True, target='showItems')}}' call in 
the html, automatically creates a div id='showItems'.  This was further 
evidenced by my own application, where I do not explicitly create a div tag 
with id=patient, but when I view pagesource for my opening page (which 
works OK) and has the call  
{{ 
=LOAD('default','post.load',ajax=True,target='patient',vars={'scanId':1}) 
}}, the resulting page source does include a 'loading...' element.



 

 

#
### - default.py  ###
#


def index():
import webgrid
from gluon.tools import Crud
crud = Crud(icc_db)
grid=webgrid.WebGrid(crud)
grid.datasource = icc_db(icc_db.scan.id>0)
grid.pagesize = 10
grid.action_links = ['view']
grid.action_headers = ['view']
grid.enabled_rows = ['header','pager','footer']
grid.crud_function = 'viewPatient'
   
return dict(grid=grid())

def viewPatient():
  scanId=request.args[2] #ignoring this whilst debugging, and hard-coding 
scanId=4 below..

[web2py] Re: Why would this happen?

2012-06-02 Thread LightDot
Doesn't work when served trough web2py, even if converted to unicode and 
even if additionally percent-escaped. I see these choices:

- serve the file from the same location but directly trough another web 
server, bypassing web2py altogether (works fine in apache)
- if the contract must be served trough web2py and stored directly into 
static/documents, a quick and dirty solution would be to use pinyin rather 
than Chinese characters in the file name. Mei wenti :)
- if the file name must contain characters, you can use web2py's 
upload/download mechanism to upload / encode and later decode / retrieve 
the file name safely
- if you want to skip using the database, you could write a custom download 
function by using response.stream and response.headers.

In case of a custom function I'd be careful about directory traversal or 
any similar vectors of attack. Web2py's upload/download mechanism has this 
taken care of. And I'd test this download separately in IE, in any case. 
I've stumbled on IE's quirks with such file names before...

Regards


On Saturday, June 2, 2012 9:08:28 AM UTC+2, Bruce Wade wrote:
>
> http://127.0.0.1:8000/yaw/en/static/documents/adspaces.js?attachement  
> allows me to download the js file
> http://127.0.0.1:8000/yaw/en/static/documents/�得世界网广告服务协议.pdf?attachement 
> gives me "Invalid Request" both files exist.
>
> Basically I have some files in static/documents I want to allow to be 
> downloaded. What is the correct way to accomplish this?
>
> -- 
> -- 
> Regards,
> Bruce Wade
> http://ca.linkedin.com/in/brucelwade
> http://www.wadecybertech.com
> http://www.fittraineronline.com - Fitness Personal Trainers Online
> http://www.warplydesigned.com
>
>

[web2py] Re: using ajax and load for modular applications

2012-06-02 Thread Andrew
I didn't know that.  I've always specified so that I could control where in the 
HTML it would go.


Re: [web2py] Hebrew encoding

2012-06-02 Thread Udi Milo
What I want to do is just to get the & characters into Hebrew, and I 
don't want to touch the rest. I don't care that it has invalid HTML tags.
I don't understand how an encoding method has an exception on invalid 
tags... how are the two issues related?


On Saturday, June 2, 2012 1:46:18 AM UTC-4, mweissen wrote:
>
> Hi Udi,
>
> I have tried it once again.
> I had to change from   to  and from  to .
> "unescape" works now!
>
> But it would be interesting to learn about more this problem. Could you 
> please answer Massimos questions? 
>
> 2012/6/2 Massimo Di Pierro 
>
>> I am not sure there is an error here. Is the problem that the characters 
>> are not dissplayed properly? Are you using a custom layout? If so, is it 
>> setting the utf8 encoding or does it tell the browser it is latin1?
>>
>> On Friday, 1 June 2012 15:45:45 UTC-5, Udi Milo wrote:
>>>
>>> It does, but not completely,
>>>
>>> As it turns out what I copy pasted was part of it, and your function 
>>> does work perfectly. when I try to run it on the entire text, I get errors 
>>> that I can't figure our, maybe you can help me once more?
>>> here is the complete text:
>>>
>>> 
>>> 
>>> ...
>>>
>>
>>> 
>>>
>>> Thanks!
>>>
>>>
>>> On Friday, June 1, 2012 1:45:32 AM UTC-4, mweissen wrote:

 I have found at 
 http://wiki.python.org/moin/**EscapingXml
 :

 import xml.parsers.expat

 def unescape(s):
 want_unicode = False
 if isinstance(s, unicode):
 s = s.encode("utf-8")
 want_unicode = True

 # the rest of this assumes that `s` is UTF-8
 list = []

 # create and initialize a parser object
 p = xml.parsers.expat.**ParserCreate("utf-8")
 p.buffer_text = True
 p.returns_unicode = want_unicode
 p.CharacterDataHandler = list.append

 # parse the data wrapped in a dummy element
 # (needed so the "document" is well-formed)
 p.Parse("", 0)
 p.Parse(s, 0)
 p.Parse("", 1)

 # join the extracted strings and return
 es = ""
 if want_unicode:
 es = u""
 return es.join(list)

 With

 t="""מפת&#**x5D7;ים 
 רבים מבקש&#**x5D9;ם 
 את עזרת&#**x5D9; 
 בפתר&#**x5D5;ן 
 בעיו&#**x5EA; של 
 ביצו&#**x5E2;י Visual Studio. 
 \nבד”&#**x5DB; את רוב 
 הבעי&#**x5D5;ת 
 ניתן לפתו&#**x5E8; 
 יחסי&#**x5EA; 
 בקלו&#**x5EA;, 
 \nוככל שעוב&#**x5E8; 
 הזמן אני 
 מוצא את עצמי 
 מספק פחות או 
 יותר את אותן 
 התשו&#**x5D1;ות, \nמה 
 שגרם לי לחשו&#
 **x5D1; שכנר&#**x5D0;ה 
 הגיע הזמן 
 להעל&#**x5D5;ת 
 אותן בצור&#**x5D4; 
 מסוד&#**x5E8;ת 
 לפוס&#**x5D8;."""
 print unescape (t)

 the result is

 מפתחים רבים מבקשים את עזרתי בפתרון בעיות של ביצועי Visual Studio. 
 בד”כ את רוב הבעיות ניתן לפתור יחסית בקלות, 
 וככל שעובר הזמן אני מוצא את עצמי מספק פחות או יותר את אותן התשובות, 
 מה שגרם לי לחשוב שכנראה הגיע הזמן להעלות אותן בצורה מסודרת לפוסט.

 I hope it helps.
 Regards Martin

 2012/6/1 Udi Milo 

> part of my product receives user text, saves it and shows it later.
>
> one of my users added a hebrew text attached below and I do not know 
> how to translate it into letter instead of hex.
> simple text.encode('UTF-8') doesn't work, and I am far from being an 
> expert in the subject. can someone help me out?
>
> see attached text:
>
> מפתח&#**x5D9;ם 
> רבים מבקש&#**x5D9;ם 
> את עזרת&#**x5D9; 
> בפתר&#**x5D5;ן 
> בעיו&#**x5EA; של 
> ביצו&#**x5E2;י Visual Studio. 
> בד”כ את רוב 
> הבעי&#**x5D5;ת 
> ניתן לפתו&#**x5E8; 
> יחסי&#**x5EA; בקלו&#**
> x5EA;, 
> וככל שעוב&#**x5E8; 
> הזמן אני 
> מוצא את עצמי 
> מספק פחות או 
> יותר את אותן 
> התשו&#**x5D1;ות, 
> מה שגרם לי 
> לחשו&#**x5D1; 
> שכנר&#**x5D0;ה 
> הגיע הזמן 
> להעל&#**x5D5;ת 
> אותן בצור&#**x5D4; 
> מסוד&#**x5E8;ת 
> לפוס&#**x5D8;.
>



 

[web2py] query from sql to code in web2py

2012-06-02 Thread Annet
I have the following where close in a query:

WHERE nodeid=283 and ((dayid=6 and starttime>'11:00:00')or(dayid>6));

In Postgresql this query outputs the right data.

I translated this query into the following code in a function:

rows=db((db.Timetable.nodeID==session.id)&(((db.Timetable.dayID==6)&(db.Timetable.startTime>'11:00:00'))or(db.Timetable.dayID>6))).select()

In web2py this code results in an empty rows object. What's the correct 
syntax for this query?


Kind regards,

Annet.


Re: [web2py] Re: Why would this happen?

2012-06-02 Thread Bruce Wade
Awe,

Ok so on my production servers I use nginx to serve all static so this
should work? I am not storing the files in the database, the CEO just wants
the ability for members to download these files. I guess there is really no
way to test this locally using python web2py to start the application.

I will see if nginx allows the files to be downloaded.

PS: Even with an English titled file it still doesn't work. IE:
http://127.0.0.1:8000/yaw/en/**static/documents/
test.**pdf?attachement
--
Regards,
Bruce

On Sat, Jun 2, 2012 at 7:08 AM, LightDot  wrote:

> Doesn't work when served trough web2py, even if converted to unicode and
> even if additionally percent-escaped. I see these choices:
>
> - serve the file from the same location but directly trough another web
> server, bypassing web2py altogether (works fine in apache)
> - if the contract must be served trough web2py and stored directly into
> static/documents, a quick and dirty solution would be to use pinyin rather
> than Chinese characters in the file name. Mei wenti :)
> - if the file name must contain characters, you can use web2py's
> upload/download mechanism to upload / encode and later decode / retrieve
> the file name safely
> - if you want to skip using the database, you could write a custom
> download function by using response.stream and response.headers.
>
> In case of a custom function I'd be careful about directory traversal or
> any similar vectors of attack. Web2py's upload/download mechanism has this
> taken care of. And I'd test this download separately in IE, in any case.
> I've stumbled on IE's quirks with such file names before...
>
> Regards
>
>
>
> On Saturday, June 2, 2012 9:08:28 AM UTC+2, Bruce Wade wrote:
>
>> http://127.0.0.1:8000/yaw/en/**static/documents/adspaces.js?**attachement
>> allows me to download the js file
>> http://127.0.0.1:8000/yaw/en/**static/documents/
>> �得世界网广告服务协议.**pdf?attachement gives me "Invalid Request" both files
>> exist.
>>
>>
>> Basically I have some files in static/documents I want to allow to be
>> downloaded. What is the correct way to accomplish this?
>>
>> --
>> --
>> Regards,
>> Bruce Wade
>> http://ca.linkedin.com/in/**brucelwade
>> http://www.wadecybertech.com
>> http://www.fittraineronline.**com  -
>> Fitness Personal Trainers Online
>> http://www.warplydesigned.com
>>
>>


-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.fittraineronline.com - Fitness Personal Trainers Online
http://www.warplydesigned.com


[web2py] Re: using ajax and load for modular applications

2012-06-02 Thread Anthony

>
> In the book example, response.ajax (which should be response.js) is set in 
>> the edit_items() function, which is always called as an Ajax component. You 
>> are setting it in your view() function, but I can't see where that function 
>> is actually called, so I don't know if it is being called as an Ajax 
>> component or as a regular web page.
>
>
> [[NB: To avoid confusion, in the code (included below) I've updated this 
> function name to be viewPatient().]]  
> This viewPatient() function is set as the webGrid.crud_function property, 
> within my index() function of default.py 
> (grid.crud_function = 'viewPatient'). I believe the answer to your 
> question is that it is called as a regular webpage, 
> as webGrid is not an ajax component.
>

OK, in that case, setting response.js in viewPatient() won't have any 
effect (by the way, Python prefers view_patient rather than camel case for 
functions and variables -- 
http://www.python.org/dev/peps/pep-0008/#prescriptive-naming-conventions). 
If viewPatient() is simply called as a regular full web page, then to run 
some JS on the page when it loads, you'll have to add a script element with 
the JS code inside a jQuery document ready. In this case, though, that's 
not necessary because it appears you simply want to load a web2py Ajax 
component on that page, which you can simply do by including the LOAD() 
helper in the viewPatient view.

More generally, it does not appear that what you are trying to do exactly 
mirrors the structure of the book example you are copying, so you might be 
better off ignoring that example. Instead, be sure to read 
http://web2py.com/books/default/chapter/29/12#Components. The cookbook is 
generally more advanced and assumes a firm understanding of how the 
framework works. Attempting to alter the examples without understanding the 
underlying functionality is not likely to be a fruitful approach.

Yes. Since reading your comments, and looking at the page-source for the 
> (successful) initial index page upload, I've updated this to:
>
> response.js = \
>   
> 'web2py_component("/ICC_Data_Management/default/post.load?scanId=4","patient");'
>  
> \
>   % URL('/ICC_Data_Management/default/post.load?scanId=4') 
>
> ... and this returns the error:   ' not 
> enough information to build the url'
>

You are passing a fully constructed url to the URL() function -- that's not 
how it works. You probably want:

response.js = 'web2py_component("%s", "patient");' % URL('default', 
'post.load', vars=dict(scanId=4))

But as mentioned above, response.js isn't really appropriate in this case.

+ to answer the question from Andrew, in a seperate message: 
> ---'Also, I don't see a div with an Id = patient.  That's your target.   
> Is it in the code but not in your post?'
>
> From the example in the book, it appears (to me) to imply that the 
> '{{=LOAD('default', 'list_items', ajax=True, target='showItems')}}' call in 
> the html, automatically creates a div id='showItems'.  This was further 
> evidenced by my own application, where I do not explicitly create a div tag 
> with id=patient, but when I view pagesource for my opening page (which 
> works OK) and has the call  
> {{ 
> =LOAD('default','post.load',ajax=True,target='patient',vars={'scanId':1}) 
> }}, the resulting page source does include a ' id="patient">loading...' element.
>

Yes, this is correct. If you call LOAD() without specifying a target, it 
will generate a div with a random id, but if you specify a value for 
target, it will use that value as the id for the div it generates. Note, if 
you just call web2py_component() by itself on the client side, it will not 
generate the div for you, so the div must already exist on the page in that 
case (the LOAD() helper is executed on the server side when the page is 
first requested and generates the div at that time).

Anthony


Re: [web2py] Re: Why would this happen?

2012-06-02 Thread Bruce Wade
Yeah that fixed that one problem

I found IF there is a space in the file name it will not work, and if it
doesn't use ascii characters as LighDot said it wont work. Do you know
which part of web2py code handles this or if it is possible to make it work
with Chinese Characters?

On Sat, Jun 2, 2012 at 7:56 AM, Anthony  wrote:

> PS: Even with an English titled file it still doesn't work. IE:
>> http://127.0.0.1:8000/yaw/**en/**static/documents/
>> test.**pdf?**attachement
>>
>
> "attachement" should be "attachment" -- does that help?
>
> Anthony
>



-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.fittraineronline.com - Fitness Personal Trainers Online
http://www.warplydesigned.com


[web2py] appadmin in Romanian (for Massimo)

2012-06-02 Thread ionel
Hello Massimo,

This is the language file for appadmin in Romanian.

Thank you,

i.a.

# coding: utf8
{
'!=': '!=',
'"update" is an optional expression like "field1=\'newvalue\'". You cannot update or delete the results of a JOIN': '"update" (actualizeaz?) este o expresie op?ional? precum "c?mp1=\'valoare_nou?\'". Nu pute?i actualiza sau ?terge rezultatele unui JOIN',
'%(nrows)s records found': '%(nrows)s ?nregistr?ri g?site',
'%Y-%m-%d': '%Y-%m-%d',
'%Y-%m-%d %H:%M:%S': '%Y-%m-%d %H:%M:%S',
'%s rows deleted': '%s linii ?terse',
'%s rows updated': '%s linii actualizate',
'(requires internet access)': '(are nevoie de acces internet)',
'(something like "it-it")': '(ceva ce seam?n? cu "it-it")',
'<': '<',
'<=': '<=',
'=': '=',
'>': '>',
'>=': '>=',
'A new version of web2py is available': 'O nou? versiune de web2py este disponibil?',
'A new version of web2py is available: %s': 'O nou? versiune de web2py este disponibil?: %s',
'ATTENTION: Login requires a secure (HTTPS) connection or running on localhost.': 'ATEN?IE: Nu v? pute?i conecta dec?t utiliz?nd o conexiune securizat? (HTTPS) sau rul?nd aplica?ia pe computerul local.',
'ATTENTION: TESTING IS NOT THREAD SAFE SO DO NOT PERFORM MULTIPLE TESTS CONCURRENTLY.': 'ATEN?IE: Nu pute?i efectua mai multe teste o dat? deoarece lansarea ?n execu?ie a mai multor subpocese nu este sigur?.',
'ATTENTION: you cannot edit the running application!': 'ATEN?IE: nu pute?i edita o aplica?ie ?n curs de execu?ie!',
'Abort': 'Anuleaz?',
'About': 'Despre',
'About application': 'Despre aplica?ie',
'Access Control': 'Control acces',
'Add': 'Adaug?',
'Additional code for your application': 'Cod suplimentar pentru aplica?ie',
'Admin is disabled because insecure channel': 'Adminstrarea este dezactivat? deoarece conexiunea nu este sigur?',
'Admin is disabled because unsecure channel': 'Administrarea este dezactivat? deoarece conexiunea nu este securizat?',
'Admin language': 'Limba de administrare',
'Administration': 'Administrare',
'Administrative Interface': 'Interfa?? administrare',
'Administrator Password:': 'Parol? administrator:',
'Ajax Recipes': 'Re?ete Ajax',
'And': '?i',
'Application name:': 'Nume aplica?ie:',
'Are you sure you want to delete file "%s"?': 'Sigur ?terge?i fi?ierul "%s"?',
'Are you sure you want to delete this object?': 'Sigur ?terge?i acest obiect?',
'Are you sure you want to uninstall application "%s"': 'Sigur dezinstala?i aplica?ia "%s"',
'Are you sure you want to uninstall application "%s"?': 'Sigur dezinstala?i aplica?ia "%s"?',
'Authentication': 'Autentificare',
'Available databases and tables': 'Baze de date ?i tabele disponibile',
'Back': '?napoi',
'Begin': '?nceput',
'Buy this book': 'Cump?r? aceast? carte',
'Cache Keys': 'Chei cache',
'Cannot be empty': 'Nu poate fi vid',
'Cannot compile: there are errors in your app.Debug it, correct errors and try again.': 'Compilare imposibil?: aplica?ia con?ine erori. Deboga?i aplica?ia ?i ?ncerca?i din nou.',
'Change Password': 'Schimbare parol?',
'Change admin password': 'Schimb? parola de administrare',
'Change password': 'Schimbare parol?',
'Check for upgrades': 'Verific? dac? exist? upgrade-uri',
'Check to delete': 'Co?a?i pentru a ?terge',
'Checking for upgrades...': 'Verific? dac? exist? actualiz?ri...',
'Clean': 'Cur???',
'Clear': 'Gole?te',
'Click row to expand traceback': 'Clic pe linie pentru a extinde mesajul de trasabilitate',
'Click row to view a ticket': 'Click row to view a ticket',
'Client IP': 'IP client',
'Community': 'Comunitate',
'Compile': 'Compileaz?',
'Components and Plugins': 'Componente ?i plugin-uri',
'Controller': 'Controlor',
'Controllers': 'Controlori',
'Copyright': 'Drepturi de autor',
'Count': 'Num?r',
'Create': 'Creaz?',
'Create new application': 'Crea?i aplica?ie nou?',
'Current request': 'Cerere curent?',
'Current response': 'R?spuns curent',
'Current session': 'Sesiune curent?',
'DB Model': 'Model baz? de date',
'DESIGN': 'DESIGN',
'Database': 'Baza de date',
'Date and Time': 'Data ?i ora',
'Debug': 'Debogare',
'Delete': '?terge',
'Delete this file (you will be asked to confirm deletion)': 'Delete this file (you will be asked to confirm deletion)',
'Delete:': '?terge:',
'Demo': 'Demo',
'Deploy': 'Instalare',
'Deploy on Google App Engine': 'Instalare pe Google App Engine',
'Deployment Recipes': 'Re?ete de instalare',
'Description': 'Descriere',
'Design for': 'Design pentru',
'Detailed traceback description': 'Descriere detaliat? a mesajului de trasabilitate',
'Disable': 'Dezactiveaz?',
'Disk Cache Keys': 'Chei cache de disc',
'Documentation': 'Documenta?ie',
"Don't know what to do?": 'Nu ?ti?i ce s? face?i?',
'Download': 'Desc?rcare',
'E-mail': 'E-mail',
'E-mail invalid': 'E-mail invalid',
'EDIT': 'EDITARE',
'Edit': 'Editare',
'Edit Profile': 'Editare profil',
'Edit This App': 'Edita?i aceast? aplica?ie',
'Edit application': 'Editare aplica?ie',
'Edit current record': 'Editare ?nregistrare curent?',
'Editing file': 'Editare fi?ier',
'Editing file "%s"': 'Editare fi?ier "%s"',

[web2py] welcome in Romanian (for Massimo)

2012-06-02 Thread ionel
Hello Massimo,

This is the language file for welcome app in Romanian.

Thank you,

i.a.

# coding: utf8
{
'!=': '!=',
'"update" is an optional expression like "field1=\'newvalue\'". You cannot update or delete the results of a JOIN': '"update" (actualizeaz?) este o expresie op?ional? precum "c?mp1=\'valoare_nou?\'". Nu pute?i actualiza sau ?terge rezultatele unui JOIN',
'%(nrows)s records found': '%(nrows)s ?nregistr?ri g?site',
'%Y-%m-%d': '%Y-%m-%d',
'%Y-%m-%d %H:%M:%S': '%Y-%m-%d %H:%M:%S',
'%s rows deleted': '%s linii ?terse',
'%s rows updated': '%s linii actualizate',
'(something like "it-it")': '(ceva ce seam?n? cu "it-it")',
'<': '<',
'<=': '<=',
'=': '=',
'>': '>',
'>=': '>=',
'A new version of web2py is available': 'O nou? versiune de web2py este disponibil?',
'A new version of web2py is available: %s': 'O nou? versiune de web2py este disponibil?: %s',
'ATTENTION: Login requires a secure (HTTPS) connection or running on localhost.': 'ATEN?IE: Nu v? pute?i conecta dec?t utiliz?nd o conexiune securizat? (HTTPS) sau rul?nd aplica?ia pe computerul local.',
'ATTENTION: TESTING IS NOT THREAD SAFE SO DO NOT PERFORM MULTIPLE TESTS CONCURRENTLY.': 'ATEN?IE: Nu pute?i efectua mai multe teste o dat? deoarece lansarea ?n execu?ie a mai multor subpocese nu este sigur?.',
'ATTENTION: you cannot edit the running application!': 'ATEN?IE: nu pute?i edita o aplica?ie ?n curs de execu?ie!',
'About': 'Despre',
'About application': 'Despre aplica?ie',
'Access Control': 'Control acces',
'Add': 'Adaug?',
'Admin is disabled because insecure channel': 'Adminstrarea este dezactivat? deoarece conexiunea nu este sigur?',
'Admin is disabled because unsecure channel': 'Administrarea este dezactivat? deoarece conexiunea nu este securizat?',
'Administration': 'Administrare',
'Administrative Interface': 'Interfa?? administrare',
'Administrator Password:': 'Parol? administrator:',
'Ajax Recipes': 'Re?ete Ajax',
'And': '?i',
'Are you sure you want to delete file "%s"?': 'Sigur ?terge?i fi?ierul "%s"?',
'Are you sure you want to delete this object?': 'Sigur ?terge?i acest obiect?',
'Are you sure you want to uninstall application "%s"': 'Sigur dezinstala?i aplica?ia "%s"',
'Are you sure you want to uninstall application "%s"?': 'Sigur dezinstala?i aplica?ia "%s"?',
'Authentication': 'Autentificare',
'Available databases and tables': 'Baze de date ?i tabele disponibile',
'Back': '?napoi',
'Buy this book': 'Cump?r? aceast? carte',
'Cache Keys': 'Chei cache',
'Cannot be empty': 'Nu poate fi vid',
'Cannot compile: there are errors in your app.Debug it, correct errors and try again.': 'Compilare imposibil?: aplica?ia con?ine erori. Deboga?i aplica?ia ?i ?ncerca?i din nou.',
'Change Password': 'Schimbare parol?',
'Change password': 'Schimbare parol?',
'Check to delete': 'Co?a?i pentru a ?terge',
'Clear': 'Gole?te',
'Client IP': 'IP client',
'Community': 'Comunitate',
'Components and Plugins': 'Componente ?i plugin-uri',
'Controller': 'Controlor',
'Controllers': 'Controlori',
'Copyright': 'Drepturi de autor',
'Create new application': 'Crea?i aplica?ie nou?',
'Current request': 'Cerere curent?',
'Current response': 'R?spuns curent',
'Current session': 'Sesiune curent?',
'DB Model': 'Model baz? de date',
'DESIGN': 'DESIGN',
'Database': 'Baza de date',
'Date and Time': 'Data ?i ora',
'Delete': '?terge',
'Delete:': '?terge:',
'Demo': 'Demo',
'Deploy on Google App Engine': 'Instalare pe Google App Engine',
'Deployment Recipes': 'Re?ete de instalare',
'Description': 'Descriere',
'Design for': 'Design pentru',
'Disk Cache Keys': 'Chei cache de disc',
'Documentation': 'Documenta?ie',
"Don't know what to do?": 'Nu ?ti?i ce s? face?i?',
'Download': 'Desc?rcare',
'E-mail': 'E-mail',
'E-mail invalid': 'E-mail invalid',
'EDIT': 'EDITARE',
'Edit': 'Editare',
'Edit Profile': 'Editare profil',
'Edit This App': 'Edita?i aceast? aplica?ie',
'Edit application': 'Editare aplica?ie',
'Edit current record': 'Editare ?nregistrare curent?',
'Editing file': 'Editare fi?ier',
'Editing file "%s"': 'Editare fi?ier "%s"',
'Email and SMS': 'E-mail ?i SMS',
'Error logs for "%(app)s"': 'Log erori pentru "%(app)s"',
'Errors': 'Erori',
'Export': 'Export',
'FAQ': '?ntreb?ri frecvente',
'False': 'Neadev?rat',
'First name': 'Prenume',
'Forbidden': 'Interzis',
'Forms and Validators': 'Formulare ?i validatori',
'Free Applications': 'Aplica?ii gratuite',
'Functions with no doctests will result in [passed] tests.': 'Func?iile f?r? doctests vor genera teste [trecute].',
'Group %(group_id)s created': 'Grup %(group_id)s creat',
'Group ID': 'ID grup',
'Group uniquely assigned to user %(id)s': 'Grup asociat ?n mod unic utilizatorului %(id)s',
'Groups': 'Grupuri',
'Hello World': 'Salutare lume',
'Home': 'Acas?',
'How did you get here?': 'Cum a?i ajuns aici?',
'Import/Export': 'Import/Export',
'Index': 'Index',
'Installed applications': 'Aplica?ii instalate',
'Internal State': 'Stare intern?',
'Introduction': 'Introducere',
'Invalid Query': 'Interogare invalid?',
'Invalid actio

[web2py] problem with update

2012-06-02 Thread peter


In the book it says


"And you can update all records in a set by passing named arguments 
corresponding to the fields that need to be updated:

update

1.

>>> db(db.person.id > 3).update(name='Ken')

Expressions

The value assigned an update statement can be an expression. For example 
consider this model

1.
2.
3.
4.
5.

>>> db.define_table('person',
Field('name'),
Field('visits', 'integer', default=0))
>>> db(db.person.name == 'Massimo').update(
visits = db.person.visits + 1)


"

*def update():
db(db.clubs).update(postcode=db.clubs.postcode)*

*
*

*Where postcode is simply **Field('postcode') and already has a value.*

*
*

*I am doing this because I want a 'compute' field that uses the postcode to 
calculate*

*
*

*What I find is that postcode does not get updated to the value it already 
contains, but gets updated to 'clubs.postcode'.*

*This does not seem consistent with the book.*

*I know I could do a loop and update_record, but this seems to do a commit on 
each update_record, and therefore take a lot longer than*

*if I can do it in one update.*

*
*

*
*

*Peter*

*
*

*
*

* 

*




Re: [web2py] failures

2012-06-02 Thread R. Strusberg
Hi Massimo,

I can give you web2py mirrors in some Latin America countries (CO, CL, PA,
PE, MX and VE) using the LatinuxORG infraestructure. Also in Europe, France.

Regards

Ricardo Strusberg

2012/6/1 Massimo Di Pierro 

> Today the VPS that hosts web2py.com failed (not sure what but I can no
> longer ssh into it). Is to happens that yesterday the HD of my laptop
> failed. My office mac is no longer syncing emails with outlook and gmail. A
> few other random and independent things have been failing on me in the last
> few days. I just wanted to reassure you that things will be taken care of
> and web2py.com is a priority. I may be a little slow on this list as a
> result.
>
> Massimo
>


[web2py] SQLFORM list with indirect labels

2012-06-02 Thread Martin Barnard
I have some linked tables like so:

db.define_table('cities',
Field('city', 'string'),
format="%(city)s"
)
db.define_table('customers',
Field('customer', 'string'),
Field('contact_name', 'string'),
format="%(customer)s"
)
db.define_table('customers_job',
Field('city', db.cities),
Field('description', 'text'),
Field('customer', db.customer),
format="%(customer)s - %(city)s"
)
db.define_table('emp_hours',
Field('employee', db.employee),
Field('job', db.customers_jobs),
Field('work_date', 'date', default=request.now.date(), ),
Field('number_of_hours', 'integer', default=10),
)

My question is, when designing a CRUD/SQLFORM/whatever for the emp_hours 
table, I would like the *db.emp_hours.job *field widget to display the 
following in a drop-down:
   
   - db.customers.customer 
   - db.cities.city, 
   - and the first 20 chars of db.customers_jobs.description
   - (e.g. format="%(customer)s - %(city)s (%(description[:20])s)")
   

Is there any way that I can do this? I have tried constructing widgets & 
validators, etc. But because the emp_hours.job is linking to the 
customers_jobs and not the customers, it only displays the customers_jobs.id
.

Thanks in advance!


[web2py] Re: SQLFORM list with indirect labels

2012-06-02 Thread Anthony

>
> db.define_table('customers_job',
> Field('city', db.cities),
> Field('description', 'text'),
> Field('customer', db.customer),
> format="%(customer)s - %(city)s"
> )


The "format" argument to define_table() is not recursive -- the "customer" 
value in the format argument above will simply be the value of the 
"customer" field, which is an integer id referring to the db.customer 
table. The db.customer table has its own "format" argument, but that format 
is not used in constructing the formats of any referring tables. Instead of 
providing a string format, as above, you can use a callable (e.g., lambda) 
format to achieve what you want:

db.define_table('customers_job',
Field('city', db.cities),
Field('description', 'text'),
Field('customer', db.customer),
format=lambda r: '%s - %s' % (db.customer[r.customer].customer,
  db.cities[r.city].city)
)

That will take the id values of the record from the city and customer 
fields and use them to query the db.customer and db.cities tables, 
respectively, to obtain the customer and city names.

Anthony


Re: [web2py] Re: SQLFORM list with indirect labels

2012-06-02 Thread Martin Barnard
Much thanks. I've been struggling with various sub-par implementations of
this for a while. I wondered how you could get a recursive represent.

M.

On 2 June 2012 21:14, Anthony  wrote:

> db.define_table('customers_**job',
>> Field('city', db.cities),
>> Field('description', 'text'),
>> Field('customer', db.customer),
>> format="%(customer)s - %(city)s"
>> )
>
>
> The "format" argument to define_table() is not recursive -- the "customer"
> value in the format argument above will simply be the value of the
> "customer" field, which is an integer id referring to the db.customer
> table. The db.customer table has its own "format" argument, but that format
> is not used in constructing the formats of any referring tables. Instead of
> providing a string format, as above, you can use a callable (e.g., lambda)
> format to achieve what you want:
>
> db.define_table('customers_job',
> Field('city', db.cities),
> Field('description', 'text'),
> Field('customer', db.customer),
>
> format=lambda r: '%s - %s' % (db.customer[r.customer].customer,
>   db.cities[r.city].city)
> )
>
> That will take the id values of the record from the city and customer
> fields and use them to query the db.customer and db.cities tables,
> respectively, to obtain the customer and city names.
>
> Anthony
>


[web2py] bogus is_local?

2012-06-02 Thread Jonathan Lundell
I'm deploying web2py on a Rackspace VPS running Ubuntu 11.something, Apache, 
mod_wsgi, MySQL.

It's been working fine, but recently, for debugging locally, I switched to 
SQLite when is_local, so I could easily blow away my test data, etc. And *that* 
worked fine.

But now I've deployed that version of the app to Rackspace, and I'm seeing at 
least some of my remote requests showing up with is_local True. Below is a dump 
of request.env for one such request. Notice that it looks completely like a 
local request, but the server_software is Apache, and the request is coming 
from my (remote) browser.

Any idea what's going on? I can hack the is_local test, but ...



request.env: , 
'web2py_path': '/home/wupadmin/.virtualenvs/watchup/watchup/web2py', 
'http_accept': '*/*', 
'wsgi_url_scheme': 'http', 'mod_wsgi_version': (3, 3), 
'server_name': 'localhost', 
'remote_addr': '127.0.0.1', 
'is_jython': False, 
'applications_parent': '/home/wupadmin/.virtualenvs/watchup/watchup/web2py', 
'server_admin': '[no address given]', 
'mod_wsgi_request_handler': 'wsgi-script', 
'wsgi_version': (1, 1), 
'request_method': 'GET', 
'web2py_original_uri': '/', 
'server_port': '80', 
'mod_wsgi_script_reloading': '1', 
'wsgi_input': , 
'server_addr': '127.0.0.1', 
'path_translated': 
'/home/wupadmin/.virtualenvs/watchup/watchup/web2py/wsgihandler.py/', 
'wsgi_multithread': True, 
'mod_wsgi_listener_port': '80', 
'gluon_parent': '/home/wupadmin/.virtualenvs/watchup/watchup/web2py', 
'server_software': 'Apache', 
'web2py_version': (2, 0, 0, datetime.datetime(2012, 5, 12, 3, 53, 36), 'dev'), 
'http_host': 'localhost', 
'path_info': '/', 
'mod_wsgi_callable_object': 'application', 
'mod_wsgi_application_group': '198.101.194.206|', 
'request_uri': '/watchup/default/index', 
'http_connection': 'close', 
'wsgi_file_wrapper': , 
'wsgi_multiprocess': False, 
'is_pypy': False, 
'mod_wsgi_input_chunked': '0', 
'gateway_interface': 'CGI/1.1', 
'app_folders': 
set(['/home/wupadmin/.virtualenvs/watchup/watchup/web2py/applications/admin/', 
'/home/wupadmin/.virtualenvs/watchup/watchup/web2py/applications/watchup/']), 
'db_sessions': set([]), 
'server_signature': '', 
'mod_wsgi_handler_script': '', 
'remote_port': '34602', 
'query_string': '', 'wsgi_run_once': False, 
'document_root': '/etc/apache2/htdocs', 
'mod_wsgi_process_group': 'web2py'}>



Re: [web2py] Re: Thinking of building a bug tracker...

2012-06-02 Thread Massimo Di Pierro
I had not seen it. Looks really slick.

On Friday, 1 June 2012 23:49:31 UTC-5, Bruce Wade wrote:
>
> i-track is the winner I already have it integrated into my project and 
> will build off of it.
>
> On Fri, Jun 1, 2012 at 7:01 AM, Bruce Wade  wrote:
>
>> issue tracker there is an error when you click on projects on the demo 
>> not a good example :D
>> i-track looks like a very good starting point if we want to build of an 
>> existing product.
>>
>>
>> On Fri, Jun 1, 2012 at 12:37 AM, Jason (spot) Brower > > wrote:
>>
>>> issue tracker I know of... 
>>> I am looking at itracker now
>>> Thanks. :)
>>>
>>>
>>> On Fri, Jun 1, 2012 at 10:31 AM, stefaan wrote:
>>>



 I have noticed one other tracker in web2py, but I couldn't demo it. 
>
> Have you seen these? 

 http://code.google.com/p/web2py-issuetracker/
 http://www.i-track.org/ 


>>>
>>
>>
>> -- 
>> -- 
>> Regards,
>> Bruce Wade
>> http://ca.linkedin.com/in/brucelwade
>> http://www.wadecybertech.com
>> http://www.fittraineronline.com - Fitness Personal Trainers Online
>> http://www.warplydesigned.com
>>
>>
>
>
> -- 
> -- 
> Regards,
> Bruce Wade
> http://ca.linkedin.com/in/brucelwade
> http://www.wadecybertech.com
> http://www.fittraineronline.com - Fitness Personal Trainers Online
> http://www.warplydesigned.com
>
>

[web2py] Re: Invalid Circual Reference - misleading error message

2012-06-02 Thread Massimo Di Pierro
which web2py version?

On Saturday, 2 June 2012 06:15:41 UTC-5, François Delpierre wrote:
>
> Hi,
>
> I'm getting (again) stuck with an "Invalid Circual Reference" using 
> Wizard. Finally, it looks like I have been able to fix it by just changing 
> the order of the table in my wizard, so the table order counts in the 
> wizard. We must have listed first all the tables to which we want to refer 
> in the table we are defining.
>
>
>- The error message should really be adapted in this case, and point 
>to the line where the field is referencing a "non yet fully defined table".
>- We must be able to reorder tables, especially when using the "Edit 
>All" button in the Wizard.
>
>
> Regards,
>


[web2py] Re: Time Field

2012-06-02 Thread Massimo Di Pierro
IS_TIME(format="%H:%M") may do it.

On Saturday, 2 June 2012 06:34:35 UTC-5, villas wrote:
>
> Does anyone know a good way to exclude seconds when displaying and working 
> with time fields?
>
> I looked at IS_TIME but it still doesn't have a formatter and I'm not sure 
> how to do it.  However,  I guess there aren't many ways to format the 
> time,  so just having the seconds optional would be good.  Maybe we could 
> have something like:  IS_TIME(showseconds=True)
>
> Regards,  David
>


[web2py] Re: Date Types

2012-06-02 Thread Massimo Di Pierro
I get something different. What test dod you make?

>>> 
db.define_table('x',Field('a','date'),Field('b','time'),Field('c','datetime'))
>>> db.x.insert(a='2012-1-1',b='8:30:00',c='2012-1-1 8:30:00')
1
>>> print db.x[1]
 at 
0x10b9fa2a8>, 'id': 1, 'delete_record':  at 0x10b9fa398>}>

On Saturday, 2 June 2012 06:45:12 UTC-5, villas wrote:
>
>
> I notice that:
> form.vars.date_field == str
> form.vars.time_field == datetime.time
> form.vars.datetime_field == datetime.datetime
>
> Maybe it's just an anomally?  I seem to lose a lot of time getting date 
> and time fields from one format to another.  I wonder whether there is a 
> good resource anywhere which explains how to convert, add and subtract them 
> etc?
>


Re: [web2py] Re: Thinking of building a bug tracker...

2012-06-02 Thread Anthony
Yes, that's one of Julio's, creator of http://www.qa-stack.com/ and 
http://pyforum.org/. All three are listed on the Powered By site.

Anthony

On Saturday, June 2, 2012 3:13:40 PM UTC-4, Massimo Di Pierro wrote:
>
> I had not seen it. Looks really slick.
>
> On Friday, 1 June 2012 23:49:31 UTC-5, Bruce Wade wrote:
>>
>> i-track is the winner I already have it integrated into my project and 
>> will build off of it.
>>
>> On Fri, Jun 1, 2012 at 7:01 AM, Bruce Wade  wrote:
>>
>>> issue tracker there is an error when you click on projects on the demo 
>>> not a good example :D
>>> i-track looks like a very good starting point if we want to build of an 
>>> existing product.
>>>
>>>
>>> On Fri, Jun 1, 2012 at 12:37 AM, Jason (spot) Brower <
>>> encomp...@gmail.com> wrote:
>>>
 issue tracker I know of... 
 I am looking at itracker now
 Thanks. :)


 On Fri, Jun 1, 2012 at 10:31 AM, stefaan wrote:

>
>
>
> I have noticed one other tracker in web2py, but I couldn't demo it. 
>>
>> Have you seen these? 
>
> http://code.google.com/p/web2py-issuetracker/
> http://www.i-track.org/ 
>
>

>>>
>>>
>>> -- 
>>> -- 
>>> Regards,
>>> Bruce Wade
>>> http://ca.linkedin.com/in/brucelwade
>>> http://www.wadecybertech.com
>>> http://www.fittraineronline.com - Fitness Personal Trainers Online
>>> http://www.warplydesigned.com
>>>
>>>
>>
>>
>> -- 
>> -- 
>> Regards,
>> Bruce Wade
>> http://ca.linkedin.com/in/brucelwade
>> http://www.wadecybertech.com
>> http://www.fittraineronline.com - Fitness Personal Trainers Online
>> http://www.warplydesigned.com
>>
>>

[web2py] Re: welcome in Romanian (for Massimo)

2012-06-02 Thread Massimo Di Pierro
Both in trunk. Thanks. Please email me your full name for proper 
acknowledgements.

On Saturday, 2 June 2012 10:31:27 UTC-5, ionel wrote:
>
> Hello Massimo,
>
> This is the language file for welcome app in Romanian.
>
> Thank you,
>
> i.a.
>
>

[web2py] Re: problem with update

2012-06-02 Thread Massimo Di Pierro
Please open a ticket abut his.

On Saturday, 2 June 2012 10:47:54 UTC-5, peter wrote:
>
> In the book it says
>
>
> "And you can update all records in a set by passing named arguments 
> corresponding to the fields that need to be updated:
>
> update
>
> 1.
>
> >>> db(db.person.id > 3).update(name='Ken')
>
> Expressions
>
> The value assigned an update statement can be an expression. For example 
> consider this model
>
> 1.
> 2.
> 3.
> 4.
> 5.
>
> >>> db.define_table('person',
> Field('name'),
> Field('visits', 'integer', default=0))
> >>> db(db.person.name == 'Massimo').update(
> visits = db.person.visits + 1)
>
>
> "
>
> *def update():
> db(db.clubs).update(postcode=db.clubs.postcode)*
>
> *
> *
>
> *Where postcode is simply **Field('postcode') and already has a value.*
>
> *
> *
>
> *I am doing this because I want a 'compute' field that uses the postcode to 
> calculate*
>
> *
> *
>
> *What I find is that postcode does not get updated to the value it already 
> contains, but gets updated to 'clubs.postcode'.*
>
> *This does not seem consistent with the book.*
>
> *I know I could do a loop and update_record, but this seems to do a commit on 
> each update_record, and therefore take a lot longer than*
>
> *if I can do it in one update.*
>
> *
> *
>
> *
> *
>
> *Peter*
>
> *
> *
>
> *
> *
>
> * 
>
> *
>
>
>

Re: [web2py] failures

2012-06-02 Thread Massimo Di Pierro
Thank you Ricardo. I really need help with time. Do you need my help to 
create the mirrors? What should I do?

On Saturday, 2 June 2012 10:49:20 UTC-5, strusberg wrote:
>
> Hi Massimo,
>
> I can give you web2py mirrors in some Latin America countries (CO, CL, PA, 
> PE, MX and VE) using the LatinuxORG infraestructure. Also in Europe, France.
>
> Regards
>
> Ricardo Strusberg
>
> 2012/6/1 Massimo Di Pierro 
>
>> Today the VPS that hosts web2py.com failed (not sure what but I can no 
>> longer ssh into it). Is to happens that yesterday the HD of my laptop 
>> failed. My office mac is no longer syncing emails with outlook and gmail. A 
>> few other random and independent things have been failing on me in the last 
>> few days. I just wanted to reassure you that things will be taken care of 
>> and web2py.com is a priority. I may be a little slow on this list as a 
>> result.
>>
>> Massimo
>>
>
>

[web2py] Re: bogus is_local?

2012-06-02 Thread Massimo Di Pierro
Very strange. This seems more like an apache issue than a web2py. web2py 
simply does (in main.py):

request.is_local = request.env.remote_addr in local_hosts

where remote address is in the http request as passed by the web server.

Could it be you have a visitor sharing the same virtual machine?

On Saturday, 2 June 2012 13:42:36 UTC-5, Jonathan Lundell wrote:
>
> I'm deploying web2py on a Rackspace VPS running Ubuntu 11.something, 
> Apache, mod_wsgi, MySQL. 
>
> It's been working fine, but recently, for debugging locally, I switched to 
> SQLite when is_local, so I could easily blow away my test data, etc. And 
> *that* worked fine. 
>
> But now I've deployed that version of the app to Rackspace, and I'm seeing 
> at least some of my remote requests showing up with is_local True. Below is 
> a dump of request.env for one such request. Notice that it looks completely 
> like a local request, but the server_software is Apache, and the request is 
> coming from my (remote) browser. 
>
> Any idea what's going on? I can hack the is_local test, but ... 
>
>
>
> request.env:  'debugging': False, 
> 'http_user_agent': 'monit/5.2.5', 
> 'script_filename': 
> '/home/wupadmin/.virtualenvs/watchup/watchup/web2py/wsgihandler.py', 
> 'script_name': '', 
> 'mod_wsgi_listener_host': '', 
> 'server_protocol': 'HTTP/1.1', 
> 'wsgi_errors': , 
> 'web2py_path': '/home/wupadmin/.virtualenvs/watchup/watchup/web2py', 
> 'http_accept': '*/*', 
> 'wsgi_url_scheme': 'http', 'mod_wsgi_version': (3, 3), 
> 'server_name': 'localhost', 
> 'remote_addr': '127.0.0.1', 
> 'is_jython': False, 
> 'applications_parent': 
> '/home/wupadmin/.virtualenvs/watchup/watchup/web2py', 
> 'server_admin': '[no address given]', 
> 'mod_wsgi_request_handler': 'wsgi-script', 
> 'wsgi_version': (1, 1), 
> 'request_method': 'GET', 
> 'web2py_original_uri': '/', 
> 'server_port': '80', 
> 'mod_wsgi_script_reloading': '1', 
> 'wsgi_input': , 
> 'server_addr': '127.0.0.1', 
> 'path_translated': '/home/wupadmin/.virtualenvs/watchup/watchup/web2py/
> wsgihandler.py/', 
> 'wsgi_multithread': True, 
> 'mod_wsgi_listener_port': '80', 
> 'gluon_parent': '/home/wupadmin/.virtualenvs/watchup/watchup/web2py', 
> 'server_software': 'Apache', 
> 'web2py_version': (2, 0, 0, datetime.datetime(2012, 5, 12, 3, 53, 36), 
> 'dev'), 
> 'http_host': 'localhost', 
> 'path_info': '/', 
> 'mod_wsgi_callable_object': 'application', 
> 'mod_wsgi_application_group': '198.101.194.206|', 
> 'request_uri': '/watchup/default/index', 
> 'http_connection': 'close', 
> 'wsgi_file_wrapper':  object at 0x7f287e3d44e0>, 
> 'wsgi_multiprocess': False, 
> 'is_pypy': False, 
> 'mod_wsgi_input_chunked': '0', 
> 'gateway_interface': 'CGI/1.1', 
> 'app_folders': 
> set(['/home/wupadmin/.virtualenvs/watchup/watchup/web2py/applications/admin/',
>  
> '/home/wupadmin/.virtualenvs/watchup/watchup/web2py/applications/watchup/']), 
>
> 'db_sessions': set([]), 
> 'server_signature': '', 
> 'mod_wsgi_handler_script': '', 
> 'remote_port': '34602', 
> 'query_string': '', 'wsgi_run_once': False, 
> 'document_root': '/etc/apache2/htdocs', 
> 'mod_wsgi_process_group': 'web2py'}> 
>
>

Re: [web2py] Re: bogus is_local?

2012-06-02 Thread Jonathan Lundell
On Jun 2, 2012, at 12:42 PM, Massimo Di Pierro wrote:
> Very strange. This seems more like an apache issue than a web2py. web2py 
> simply does (in main.py):
> 
> request.is_local = request.env.remote_addr in local_hosts
> 
> where remote address is in the http request as passed by the web server.
> 
> Could it be you have a visitor sharing the same virtual machine?

I don't think so; it's a dedicate VPS and web2py is the only app running.

I thought it might be some odd misconfiguration of static fetches (don't ask me 
what), but they seem to be working fine.

Hmm. I'm looking at the Apache access logs, and I see this every 10 minutes. 
Looks like there's some local process querying the server for monitoring 
purposes, a surprise to me. I'll check with Rackspace to see what it is. 

That suggests another workaround: I don't actually need the database for my 
default controller, so I can make my table definitions dependent on the 
controllers that need them. I'll report back if I find anything out.

localhost - - [02/Jun/2012:19:45:02 +] "GET /server-status?auto HTTP/1.1" 
200 242
localhost - - [02/Jun/2012:19:45:03 +] "GET /server-status?auto HTTP/1.1" 
200 242
localhost - - [02/Jun/2012:19:45:04 +] "GET /server-status?auto HTTP/1.1" 
200 241
127.0.0.1 - - [02/Jun/2012:19:45:06 +] "GET / HTTP/1.0" 200 6067
127.0.0.1 - - [02/Jun/2012:19:45:06 +] "GET /robots.txt HTTP/1.0" 200 46
127.0.0.1 - - [02/Jun/2012:19:45:06 +] "GET /watchup/static/favicon.ico 
HTTP/1.0" 200 198
127.0.0.1 - - [02/Jun/2012:19:45:06 +] "GET 
/watchup/static/js/modernizr.custom.js HTTP/1.0" 200 13677
127.0.0.1 - - [02/Jun/2012:19:45:06 +] "GET /watchup/static/js/jquery.js 
HTTP/1.0" 200 93869
127.0.0.1 - - [02/Jun/2012:19:45:06 +] "GET 
/watchup/static/css/calendar.css HTTP/1.0" 200 2941
127.0.0.1 - - [02/Jun/2012:19:45:06 +] "GET /watchup/static/js/calendar.js 
HTTP/1.0" 200 45256
127.0.0.1 - - [02/Jun/2012:19:45:06 +] "GET /watchup/static/js/web2py.js 
HTTP/1.0" 200 6305
127.0.0.1 - - [02/Jun/2012:19:45:06 +] "GET 
/watchup/static/css/skeleton.css HTTP/1.0" 200 21946
127.0.0.1 - - [02/Jun/2012:19:45:06 +] "GET /watchup/static/css/web2py.css 
HTTP/1.0" 200 10139
127.0.0.1 - - [02/Jun/2012:19:45:06 +] "GET 
/watchup/static/css/superfish.css HTTP/1.0" 200 3627
127.0.0.1 - - [02/Jun/2012:19:45:06 +] "GET /watchup/static/js/superfish.js 
HTTP/1.0" 200 8465
127.0.0.1 - - [02/Jun/2012:19:45:06 +] "GET 
/watchup/static/images/poweredby.png HTTP/1.0" 200 4150
127.0.0.1 - - [02/Jun/2012:19:45:06 +] "GET 
/watchup/static/images/arrows-ff.png HTTP/1.0" 200 244
127.0.0.1 - - [02/Jun/2012:19:45:06 +] "GET 
/watchup/static/images/shadow.png HTTP/1.0" 200 1698



> 
> On Saturday, 2 June 2012 13:42:36 UTC-5, Jonathan Lundell wrote:
> I'm deploying web2py on a Rackspace VPS running Ubuntu 11.something, Apache, 
> mod_wsgi, MySQL. 
> 
> It's been working fine, but recently, for debugging locally, I switched to 
> SQLite when is_local, so I could easily blow away my test data, etc. And 
> *that* worked fine. 
> 
> But now I've deployed that version of the app to Rackspace, and I'm seeing at 
> least some of my remote requests showing up with is_local True. Below is a 
> dump of request.env for one such request. Notice that it looks completely 
> like a local request, but the server_software is Apache, and the request is 
> coming from my (remote) browser. 
> 
> Any idea what's going on? I can hack the is_local test, but ... 
> 
> 
> 
> request.env:  'debugging': False, 
> 'http_user_agent': 'monit/5.2.5', 
> 'script_filename': 
> '/home/wupadmin/.virtualenvs/watchup/watchup/web2py/wsgihandler.py', 
> 'script_name': '', 
> 'mod_wsgi_listener_host': '', 
> 'server_protocol': 'HTTP/1.1', 
> 'wsgi_errors': , 
> 'web2py_path': '/home/wupadmin/.virtualenvs/watchup/watchup/web2py', 
> 'http_accept': '*/*', 
> 'wsgi_url_scheme': 'http', 'mod_wsgi_version': (3, 3), 
> 'server_name': 'localhost', 
> 'remote_addr': '127.0.0.1', 
> 'is_jython': False, 
> 'applications_parent': '/home/wupadmin/.virtualenvs/watchup/watchup/web2py', 
> 'server_admin': '[no address given]', 
> 'mod_wsgi_request_handler': 'wsgi-script', 
> 'wsgi_version': (1, 1), 
> 'request_method': 'GET', 
> 'web2py_original_uri': '/', 
> 'server_port': '80', 
> 'mod_wsgi_script_reloading': '1', 
> 'wsgi_input': , 
> 'server_addr': '127.0.0.1', 
> 'path_translated': 
> '/home/wupadmin/.virtualenvs/watchup/watchup/web2py/wsgihandler.py/', 
> 'wsgi_multithread': True, 
> 'mod_wsgi_listener_port': '80', 
> 'gluon_parent': '/home/wupadmin/.virtualenvs/watchup/watchup/web2py', 
> 'server_software': 'Apache', 
> 'web2py_version': (2, 0, 0, datetime.datetime(2012, 5, 12, 3, 53, 36), 
> 'dev'), 
> 'http_host': 'localhost', 
> 'path_info': '/', 
> 'mod_wsgi_callable_object': 'application', 
> 'mod_wsgi_application_group': '198.101.194.206|', 
> 'request_uri': '/watchup/default/index', 
> 'http_connection': 'close', 
> 'wsgi_file_wr

[web2py] Re: Date Types

2012-06-02 Thread villas
It was not using the fields directly but taking the values of the returned 
form.vars.  I have refactored my code now and cannot see where it was an 
issue.  If I see it again I will make a proper test case. 

Dates and times drive me insane in python.  If only they would have 
flexible strtotime() function like php.

Thanks, D

On Saturday, 2 June 2012 20:20:50 UTC+1, Massimo Di Pierro wrote:
>
> I get something different. What test dod you make?
>
> >>> 
> db.define_table('x',Field('a','date'),Field('b','time'),Field('c','datetime'))
> >>> db.x.insert(a='2012-1-1',b='8:30:00',c='2012-1-1 8:30:00')
> 1
> >>> print db.x[1]
>  8, 30), 'b': datetime.time(8, 30), 'update_record':  at 
> 0x10b9fa2a8>, 'id': 1, 'delete_record':  at 0x10b9fa398>}>
>
> On Saturday, 2 June 2012 06:45:12 UTC-5, villas wrote:
>>
>>
>> I notice that:
>> form.vars.date_field == str
>> form.vars.time_field == datetime.time
>> form.vars.datetime_field == datetime.datetime
>>
>> Maybe it's just an anomally?  I seem to lose a lot of time getting date 
>> and time fields from one format to another.  I wonder whether there is a 
>> good resource anywhere which explains how to convert, add and subtract them 
>> etc?
>>
>

Re: [web2py] Re: bogus is_local?

2012-06-02 Thread Jonathan Lundell
On Jun 2, 2012, at 12:58 PM, Jonathan Lundell wrote:
> 
> On Jun 2, 2012, at 12:42 PM, Massimo Di Pierro wrote:
>> Very strange. This seems more like an apache issue than a web2py. web2py 
>> simply does (in main.py):
>> 
>>request.is_local = request.env.remote_addr in local_hosts
>> 
>> where remote address is in the http request as passed by the web server.
>> 
>> Could it be you have a visitor sharing the same virtual machine?
> 
> I don't think so; it's a dedicate VPS and web2py is the only app running.
> 
> I thought it might be some odd misconfiguration of static fetches (don't ask 
> me what), but they seem to be working fine.
> 
> Hmm. I'm looking at the Apache access logs, and I see this every 10 minutes. 
> Looks like there's some local process querying the server for monitoring 
> purposes, a surprise to me. I'll check with Rackspace to see what it is. 
> 
> That suggests another workaround: I don't actually need the database for my 
> default controller, so I can make my table definitions dependent on the 
> controllers that need them. I'll report back if I find anything out.

Here's a clue:

> 'http_user_agent': 'monit/5.2.5', 

monit is a monitoring agent. 

Now to find out how to shut it off gracefully. Either that or I can detect the 
user agent and feed it something harmless.



> 
> localhost - - [02/Jun/2012:19:45:02 +] "GET /server-status?auto HTTP/1.1" 
> 200 242
> localhost - - [02/Jun/2012:19:45:03 +] "GET /server-status?auto HTTP/1.1" 
> 200 242
> localhost - - [02/Jun/2012:19:45:04 +] "GET /server-status?auto HTTP/1.1" 
> 200 241
> 127.0.0.1 - - [02/Jun/2012:19:45:06 +] "GET / HTTP/1.0" 200 6067
> 127.0.0.1 - - [02/Jun/2012:19:45:06 +] "GET /robots.txt HTTP/1.0" 200 46
> 127.0.0.1 - - [02/Jun/2012:19:45:06 +] "GET /watchup/static/favicon.ico 
> HTTP/1.0" 200 198
> 127.0.0.1 - - [02/Jun/2012:19:45:06 +] "GET 
> /watchup/static/js/modernizr.custom.js HTTP/1.0" 200 13677
> 127.0.0.1 - - [02/Jun/2012:19:45:06 +] "GET /watchup/static/js/jquery.js 
> HTTP/1.0" 200 93869
> 127.0.0.1 - - [02/Jun/2012:19:45:06 +] "GET 
> /watchup/static/css/calendar.css HTTP/1.0" 200 2941
> 127.0.0.1 - - [02/Jun/2012:19:45:06 +] "GET 
> /watchup/static/js/calendar.js HTTP/1.0" 200 45256
> 127.0.0.1 - - [02/Jun/2012:19:45:06 +] "GET /watchup/static/js/web2py.js 
> HTTP/1.0" 200 6305
> 127.0.0.1 - - [02/Jun/2012:19:45:06 +] "GET 
> /watchup/static/css/skeleton.css HTTP/1.0" 200 21946
> 127.0.0.1 - - [02/Jun/2012:19:45:06 +] "GET 
> /watchup/static/css/web2py.css HTTP/1.0" 200 10139
> 127.0.0.1 - - [02/Jun/2012:19:45:06 +] "GET 
> /watchup/static/css/superfish.css HTTP/1.0" 200 3627
> 127.0.0.1 - - [02/Jun/2012:19:45:06 +] "GET 
> /watchup/static/js/superfish.js HTTP/1.0" 200 8465
> 127.0.0.1 - - [02/Jun/2012:19:45:06 +] "GET 
> /watchup/static/images/poweredby.png HTTP/1.0" 200 4150
> 127.0.0.1 - - [02/Jun/2012:19:45:06 +] "GET 
> /watchup/static/images/arrows-ff.png HTTP/1.0" 200 244
> 127.0.0.1 - - [02/Jun/2012:19:45:06 +] "GET 
> /watchup/static/images/shadow.png HTTP/1.0" 200 1698




[web2py] Re: welcome in Romanian (for Massimo)

2012-06-02 Thread ionel
Hello Massimo,

I sent you a pull request to correct the problem with the page encoding of 
the files when uploaded to web2py group. The special characters were 
replaced by "?".

Thank you,

ionel anton


On Saturday, 2 June 2012 15:36:37 UTC-4, Massimo Di Pierro wrote:
>
> Both in trunk. Thanks. Please email me your full name for proper 
> acknowledgements.
>
> On Saturday, 2 June 2012 10:31:27 UTC-5, ionel wrote:
>>
>> Hello Massimo,
>>
>> This is the language file for welcome app in Romanian.
>>
>> Thank you,
>>
>> i.a.
>>
>>

[web2py] new matplotlib library

2012-06-02 Thread Massimo Di Pierro
https://github.com/mdipierro/canvas


[web2py] return from model

2012-06-02 Thread Jonathan Lundell
I can return from the middle of a model (to conditionally short-circuit it), 
right?

Re: [web2py] new matplotlib library

2012-06-02 Thread Bruce Wade
Does this support multi-language mainly Chinese?
On Jun 2, 2012 2:39 PM, "Massimo Di Pierro" 
wrote:

> https://github.com/mdipierro/canvas
>


[web2py] App does not exist or your are not authorized when deploying layout plugin

2012-06-02 Thread François Delpierre
I just created a simple plugin as described here (Only the view/layout.html 
and a CSS) :
http://comments.gmane.org/gmane.comp.python.web2py/71183

Here is the content of the w2p plugin file :
pivert@skinner:~/Downloads$ tar -ztvf web2py.plugin.layout_name.w2p
-rw-rw francoisd/www-data 6279 2012-05-26 13:27 views/plugin_layout_name
/layout.html
drwxrwx--- francoisd/www-data0 2012-05-28 23:44 static/
plugin_layout_name/css/
-rw-rw francoisd/www-data 5237 2012-05-28 23:43 static/
plugin_layout_name/css/name.css
drwxrwx--- francoisd/www-data0 2012-05-28 23:48 static/
plugin_layout_name/images/
-rw-rw francoisd/www-data 2796 2012-05-22 23:46 static/
plugin_layout_name/images/logo-name.gif
-rw-rw francoisd/www-data  754 2012-05-22 23:46 static/
plugin_layout_name/images/header.gif



And if I deploy from the web admin interface, I have the "App does not 
exist or your are not authorized" error.


[web2py] Re: return from model

2012-06-02 Thread Massimo Di Pierro
Not sure I understand. You can return from a function defined in a model 
but it will not shortcut the model.

On Saturday, 2 June 2012 16:53:14 UTC-5, Jonathan Lundell wrote:
>
> I can return from the middle of a model (to conditionally short-circuit 
> it), right?



Re: [web2py] new matplotlib library

2012-06-02 Thread Massimo Di Pierro
All I found on the topic is this:

https://gist.github.com/2507045

I think you can use utf8 in title, labels and legend.

You can also do:

from matplotlib import 
rcrc('font',**{'family':'sans-serif','sans-serif':['Helvetica']})rc('text', 
usetex=True)


then use latex (but I do not know if latex supports chinese).



On Saturday, 2 June 2012 16:53:24 UTC-5, Bruce Wade wrote:
>
> Does this support multi-language mainly Chinese?
> On Jun 2, 2012 2:39 PM, "Massimo Di Pierro"  
> wrote:
>
>> https://github.com/mdipierro/canvas
>>
>

Re: [web2py] Re: return from model

2012-06-02 Thread Jonathan Lundell
On Jun 2, 2012, at 3:10 PM, Massimo Di Pierro wrote:
> Not sure I understand. You can return from a function defined in a model but 
> it will not shortcut the model.

I mean: return from the main line of the model itself. And you can't. I thought 
an exec might be like a function call in that respect, but it's not, and a 
return statement is just a syntax error.

Not a big deal; I can just conditionally execute the bulk of my code.

How about this: can I raise HTTP 200 from a model, and supply a simple string 
response?


> 
> On Saturday, 2 June 2012 16:53:14 UTC-5, Jonathan Lundell wrote:
> I can return from the middle of a model (to conditionally short-circuit it), 
> right?




[web2py] Re: pyfilesystem support (store uploads in S3)

2012-06-02 Thread howesc
i bet we could do something similar using the boto library on GAE.

On Thursday, May 31, 2012 10:56:47 AM UTC-7, Massimo Di Pierro wrote:
>
> Here is an example:
>
> easy_install pyfilesystem
>
> >>> import fs.s3fs
> >>> myfs = fs.s3fs.S3FS(bucket, prefix, aws_access_ke, aws_secret_key)
> >>> db.define_table('test',Field('file','upload',uploadfs = myfs))
>
> Now all your uploaded files will go on S3.
> Here is a list of supported filesystems: 
> http://packages.python.org/fs/filesystems.html
>
> WARNINGS: 
> - needs testing. I have tested with OSFS and I am confident it works
> - I do not think with will work on GAE, should be tested
> - uploadfolder and uploadseparate are ignored when uploadfs is specified 
> (this should be changed, any takers?)
>
> Should be possible to wrap myfs into an encryption layer but I have not 
> done it yet.
>
> We may want a more comprehensive strategy and allow every web2py file 
> (including apps, sessions, tickets, etc) to go into a pyfilesystem. Is this 
> necessary? On linux one can mount filesystems in a folder anyway. Is this 
> more trouble than it is worth?
>
> Massimo
>
>
>
>
>
>

Re: [web2py] Re: return from model

2012-06-02 Thread Anthony

>
> How about this: can I raise HTTP 200 from a model, and supply a simple 
> string response?
>

I believe that should work.

Anthony 


[web2py] Twitter OAuth lib

2012-06-02 Thread Udi Milo
I want to allow my users to connect a Twitter account to their account.
Which python lib do you recommend using?

Twython uses requests which I'm having difficulty running on 2.5.4 and I have 
not tried any other yet.



Re: [web2py] Re: Why would this happen?

2012-06-02 Thread Ricardo Pedroso
On Sat, Jun 2, 2012 at 4:08 PM, Bruce Wade  wrote:
> Yeah that fixed that one problem
>
> I found IF there is a space in the file name it will not work, and if it
> doesn't use ascii characters as LighDot said it wont work. Do you know which
> part of web2py code handles this or if it is possible to make it work with
> Chinese Characters?
>

It's in gluon/rewrite.py the following regex:

regex_static = re.compile(r'''
    (^                              # static pages
        /(?P \w+)                # b=app
        /static                     # /b/static
        /(?P (\w[\-\=\./]?)* )   # x=file   <--- HERE
    $)
    ''', re.X)

If you change the line marked with "HERE" to:
        /(?P (.*) )   # x=file

it should work. Be aware that could be some implications with this
change, I'm not a regex expert.

Ricardo


Re: [web2py] Re: Why would this happen?

2012-06-02 Thread Jonathan Lundell
On Jun 2, 2012, at 5:55 PM, Ricardo Pedroso wrote:
> 
> On Sat, Jun 2, 2012 at 4:08 PM, Bruce Wade  wrote:
>> Yeah that fixed that one problem
>> 
>> I found IF there is a space in the file name it will not work, and if it
>> doesn't use ascii characters as LighDot said it wont work. Do you know which
>> part of web2py code handles this or if it is possible to make it work with
>> Chinese Characters?
>> 
> 
> It's in gluon/rewrite.py the following regex:
> 
> regex_static = re.compile(r'''
> (^  # static pages
> /(?P \w+)# b=app
> /static # /b/static
> /(?P (\w[\-\=\./]?)* )   # x=file   <--- HERE
> $)
> ''', re.X)
> 
> If you change the line marked with "HERE" to:
> /(?P (.*) )   # x=file
> 
> it should work. Be aware that could be some implications with this
> change, I'm not a regex expert.

FWIW, the parametric router lets you override the regex pattern that's used for 
path validation. The default pattern is:

file_match = r'(\w+[-=./]?)+$',# legal file (path) name





Re: [web2py] Re: Why would this happen?

2012-06-02 Thread Ricardo Pedroso
On Sun, Jun 3, 2012 at 2:04 AM, Jonathan Lundell  wrote:
> On Jun 2, 2012, at 5:55 PM, Ricardo Pedroso wrote:
>>
>> On Sat, Jun 2, 2012 at 4:08 PM, Bruce Wade  wrote:
>>> Yeah that fixed that one problem
>>>
>>> I found IF there is a space in the file name it will not work, and if it
>>> doesn't use ascii characters as LighDot said it wont work. Do you know which
>>> part of web2py code handles this or if it is possible to make it work with
>>> Chinese Characters?
>>>
>>
>> It's in gluon/rewrite.py the following regex:
>>
>> regex_static = re.compile(r'''
>>     (^                              # static pages
>>         /(?P \w+)                # b=app
>>         /static                     # /b/static
>>         /(?P (\w[\-\=\./]?)* )   # x=file   <--- HERE
>>     $)
>>     ''', re.X)
>>
>> If you change the line marked with "HERE" to:
>>         /(?P (.*) )   # x=file
>>
>> it should work. Be aware that could be some implications with this
>> change, I'm not a regex expert.
>
> FWIW, the parametric router lets you override the regex pattern that's used 
> for path validation. The default pattern is:
>
>        file_match = r'(\w+[-=./]?)+$',    # legal file (path) name

I didn't now about this one, thanks Jonathan.
In fact the router mechanism is still a little bit obscure to me.

I notice now that file_match is documented in router.example.py.
So I copy router.example.py to routes.py and defined the routers dict like this:

routers = dict(
# base router
BASE = dict(
default_application = 'welcome',
file_match = r'(.*)$',# legal file (path) name
),
)

and it worked woth chinese chars in a filename.
Is this the correct place to use file_match?

Ricardo


Re: [web2py] Re: return from model

2012-06-02 Thread Massimo Di Pierro
+1

On Saturday, 2 June 2012 17:35:29 UTC-5, Anthony wrote:
>
> How about this: can I raise HTTP 200 from a model, and supply a simple 
>> string response?
>>
>
> I believe that should work.
>
> Anthony 
>


Re: [web2py] Re: Why would this happen?

2012-06-02 Thread Jonathan Lundell
On Jun 2, 2012, at 6:32 PM, Ricardo Pedroso wrote:
> 
>> FWIW, the parametric router lets you override the regex pattern that's used 
>> for path validation. The default pattern is:
>> 
>>file_match = r'(\w+[-=./]?)+$',# legal file (path) name
> 
> I didn't now about this one, thanks Jonathan.
> In fact the router mechanism is still a little bit obscure to me.
> 
> I notice now that file_match is documented in router.example.py.
> So I copy router.example.py to routes.py and defined the routers dict like 
> this:
> 
> routers = dict(
># base router
>BASE = dict(
>default_application = 'welcome',
>file_match = r'(.*)$',# legal file (path) name
>),
> )
> 
> and it worked woth chinese chars in a filename.
> Is this the correct place to use file_match?

It'd be better to restrict the change to the app in question:

routers = dict(
   # base router
   BASE = dict(
   default_application = 'welcome',
   ),
   welcome = dict(
   file_match = r'(.*)$',# legal file (path) name
   ),
)

...and you might want to be a little more restrictive than .* if you can. But 
yeah, that's the idea.

Re: [web2py] Re: Why would this happen?

2012-06-02 Thread Bruce Wade
Ok thanks I will give it a try.

On Sat, Jun 2, 2012 at 8:51 PM, Jonathan Lundell  wrote:

> On Jun 2, 2012, at 6:32 PM, Ricardo Pedroso wrote:
> >
> >> FWIW, the parametric router lets you override the regex pattern that's
> used for path validation. The default pattern is:
> >>
> >>file_match = r'(\w+[-=./]?)+$',# legal file (path) name
> >
> > I didn't now about this one, thanks Jonathan.
> > In fact the router mechanism is still a little bit obscure to me.
> >
> > I notice now that file_match is documented in router.example.py.
> > So I copy router.example.py to routes.py and defined the routers dict
> like this:
> >
> > routers = dict(
> ># base router
> >BASE = dict(
> >default_application = 'welcome',
> >file_match = r'(.*)$',# legal file (path) name
> >),
> > )
> >
> > and it worked woth chinese chars in a filename.
> > Is this the correct place to use file_match?
>
> It'd be better to restrict the change to the app in question:
>
> routers = dict(
>   # base router
>   BASE = dict(
>   default_application = 'welcome',
>),
>   welcome = dict(
>file_match = r'(.*)$',# legal file (path) name
>   ),
> )
>
> ...and you might want to be a little more restrictive than .* if you can.
> But yeah, that's the idea.




-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.fittraineronline.com - Fitness Personal Trainers Online
http://www.warplydesigned.com


Re: [web2py] Re: Why would this happen?

2012-06-02 Thread Bruce Wade
This works
routers = dict(
   # base router
   BASE = dict(
   default_application = 'welcome',
   file_match = r'(.*)$',# legal file (path) name
   ),
)

This however did not:
routers = dict(
  # base router
  BASE = dict(
  default_application = 'yaw',
  ),
  yaw = dict(
  file_match = r'(.*)$',# legal file (path) name
  ),
)

On Sat, Jun 2, 2012 at 8:57 PM, Bruce Wade  wrote:

> Ok thanks I will give it a try.
>
>
> On Sat, Jun 2, 2012 at 8:51 PM, Jonathan Lundell wrote:
>
>> On Jun 2, 2012, at 6:32 PM, Ricardo Pedroso wrote:
>> >
>> >> FWIW, the parametric router lets you override the regex pattern that's
>> used for path validation. The default pattern is:
>> >>
>> >>file_match = r'(\w+[-=./]?)+$',# legal file (path) name
>> >
>> > I didn't now about this one, thanks Jonathan.
>> > In fact the router mechanism is still a little bit obscure to me.
>> >
>> > I notice now that file_match is documented in router.example.py.
>> > So I copy router.example.py to routes.py and defined the routers dict
>> like this:
>> >
>> > routers = dict(
>> ># base router
>> >BASE = dict(
>> >default_application = 'welcome',
>> >file_match = r'(.*)$',# legal file (path) name
>> >),
>> > )
>> >
>> > and it worked woth chinese chars in a filename.
>> > Is this the correct place to use file_match?
>>
>> It'd be better to restrict the change to the app in question:
>>
>> routers = dict(
>>   # base router
>>   BASE = dict(
>>   default_application = 'welcome',
>>),
>>   welcome = dict(
>>file_match = r'(.*)$',# legal file (path) name
>>   ),
>> )
>>
>> ...and you might want to be a little more restrictive than .* if you can.
>> But yeah, that's the idea.
>
>
>
>
> --
> --
> Regards,
> Bruce Wade
> http://ca.linkedin.com/in/brucelwade
> http://www.wadecybertech.com
> http://www.fittraineronline.com - Fitness Personal Trainers Online
> http://www.warplydesigned.com
>
>


-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.fittraineronline.com - Fitness Personal Trainers Online
http://www.warplydesigned.com