[web2py] Re: ubuntu 11.10 LTS not connecting to postgres

2012-05-20 Thread weheh
Excellent, Massimo. That did the trick. Thanks for the quick response.


[web2py] Contract work to build a bridge between a C# system and a broker API, using Web2py

2012-05-20 Thread vlc
I'd like to have a simple connector/bridge built between NinjaTrader 7 
(NT7) and CityIndex API (CIAPI).  Normal practice would probably be to 
build it in C# but I'd prefer it in Python, using web2py if possible.
There is an incomplete Python version of the CIAPI library at 
http://code.google.com/p/ciapi/
Docs on the NT7 side are 
at... 
http://www.ninjatrader.com/support/helpGuides/nt7/dll_interface.htm?zoom_highlightsub=ntdirect
and there are various URLs for the CityIndex API docs but you could start 
at: https://ciapipreprod.cityindextest9.co.uk/ciapi.docs/ and at: 
https://ciapipreprod.cityindextest9.co.uk/ciapi.docs/#content.concepts
The solution may involve using a local FIX server, such as the one 
available at http://www.quickfixengine.org/

The purpose of this bridge is to allow trades to be placed using a UI other 
than the one provided by CityIndex; I would prefer to use NT7 as my UI.
I've tried to keep this message as brief as possible.  More detail 
available upon request.
I estimate the work would take 7 to 10 days.



[web2py] response.menu issue

2012-05-20 Thread Frank
hi,all,
hope get help from you, 

{{=('|'.join(A(_[0],_href=_[2]).xml() for _ in response.menu))}} suppose to be
several links on webpage, but it appear to be string on my app, how to change 
it?

thanks,

Frank



[web2py] Re: ubuntu 11.10 LTS not connecting to postgres [CLOSED]

2012-05-20 Thread weheh



Re: [web2py] Add count in db.parse_as_rest output

2012-05-20 Thread Joseph Piron
Massimo, 

here is the patch.

Thanks !


On 19 May 2012, at 21:42, Massimo Di Pierro wrote:

> yes please. Following this mailing list is getting more and more difficult 
> and number of posts increases. 
> 
> On Friday, 18 May 2012 17:26:22 UTC-5, howesc wrote:
> you could submit a patchit's more likely to get massimo to grab a patch. 
> :)
> 
> On Friday, May 18, 2012 1:06:55 AM UTC-7, Joseph.Piron wrote:
> Isn't it possible ? :(
> 
> Le lundi 23 avril 2012 10:26:35 UTC+2, Joseph.Piron a écrit :
> Hi guys! 
> 
> I am using the wonderful db.parse_as_rest function in my development and like 
> to ask if it is possible to push a modification in the trunk as as to be able 
> to go on without custom code maintenance :)
> For paging purposes, I would need the output of this function to contain the 
> total number of records returned by the request (before limits applies). 
> Fortunately, this is already computed by the function:
> if i==len(tags) and table:
> ofields = vars.get('order',db[table]._id.name).split('|')
> try:
> orderby = [db[table][f] if not f.startswith('~') else 
> ~db[table][f[1:]] for f in ofields]
> except KeyError:
> return Row({'status':400,'error':'invalid 
> orderby','response':None})
> fields = [field for field in db[table] if field.readable]
> count = dbset.count()
> try:
> offset = int(vars.get('offset',None) or 0)
> limits = (offset,int(vars.get('limit',None) or 
> 1000)+offset)
> except ValueError:
> Row({'status':400,'error':'invalid 
> limits','response':None})
> if count > limits[1]-limits[0]:
> Row({'status':400,'error':'too many 
> records','response':None})
> try:
> response = 
> dbset.select(limitby=limits,orderby=orderby,*fields)
> except ValueError:
> return Row({'status':400,'pattern':pattern,
> 'error':'invalid path','response':None})
> return 
> Row({'status':200,'response':response,'pattern':pattern})
> 
> 
> 
> and so I would modify the last return to:
> 
> return 
> Row({'status':200,'response':response,'pattern':pattern,'count':count})
> 
> Would this be acceptable ?
> 
> Thanks in advance !!

On 19 May 2012, at 21:42, Massimo Di Pierro wrote:yes please. Following this mailing list is getting more and more difficult and number of posts increases. On Friday, 18 May 2012 17:26:22 UTC-5, howesc  wrote:you could submit a patchit's more likely to get massimo to grab a patch. :)On Friday, May 18, 2012 1:06:55 AM UTC-7, Joseph.Piron wrote:Isn't it possible ? :(Le lundi 23 avril 2012 10:26:35 UTC+2, Joseph.Piron a écrit :Hi guys! I am using the wonderful db.parse_as_rest function in my development and like to ask if it is possible to push a modification in the trunk as as to be able to go on without custom code maintenance :)For paging purposes, I would need the output of this function to contain the total number of records returned by the request (before limits applies). Fortunately, this is already computed by the function:if i==len(tags) and table:                    ofields = vars.get('order',db[table]._id.name).split('|')                    try:                        orderby = [db[table][f] if not f.startswith('~') else ~db[table][f[1:]] for f in ofields]                    except KeyError:                        return Row({'status':400,'error':'invalid orderby','response':None})                    fields = [field for field in db[table] if field.readable]                    count = dbset.count()                    try:                        offset = int(vars.get('offset',None) or 0)                        limits = (offset,int(vars.get('limit',None) or 1000)+offset)                    except ValueError:                        Row({'status':400,'error':'invalid limits','response':None})                    if count > limits[1]-limits[0]:                        Row({'status':400,'error':'too many records','response':None})                    try:                        response = dbset.select(limitby=limits,orderby=orderby,*fields)                    except ValueError:                        return Row({'status':400,'pattern':pattern,                                    'error':'invalid path','response':None})                    return Row({'status':200,'response':response,'pattern':pattern})and so I would modify the last return to:                    return Row({'status':200,'response':response,'pattern':pattern,'count':count})Would this be acceptable ?Thanks in advance !!

count_patch.patch
Description: Binary data


[web2py] Re: web2py resources

2012-05-20 Thread puercoespin


El jueves, 3 de mayo de 2012 16:39:06 UTC+2, Massimo Di Pierro escribió:
>
> Please append here.


Blogs about web2py:

http://web2py.wordpress.com/

http://reingart.blogspot.com

http://thadeusb.com/weblog/category/Web2py

http://ochiba77.blogspot.com.es/

http://spametki.blogspot.com.es/ 


[web2py] Format representation in foreign table.

2012-05-20 Thread rahulserver
I have two tables:
db.define_table('Account_Master',Field('Account',requires=IS_NOT_EMPTY()),Field('Sewadari1'),Field('Mb1'),Field('Sewadari2'),Field('Mb2'),Field('City'),Field('District'),Field('State'),Field('Email'),Field('Remark'),format='%(Account)s
 
%(State)s ')

db.define_table('Transaction_Master',Field('Account',db.Account_Master,requires=IS_IN_DB(db,'Account_Master.id',
 
'%(Account)s %(State)s',zero=T('choose 
one'))),Field('Exam_Date','date'),Field('Entry_Date','date',default=request.now),Field('Form_1','upload'),Field('Form_1_Name'),Field('Schoolwise_Form','upload'),Field('Schoolwise_Form_Name'),format='%(Account)s
 
%(Exam_Date)s')

When i try to represent the account field of Transaction_Master table in 
sqlform.factory as:
 
form=SQLFORM.factory(Field('TID',requires=IS_IN_DB(db,db.Transaction_Master.id,'%(Account)s
 
%(Exam_Date)s %(id)s')))

I am getting the id field of account in the sqlform.factory form. Is there 
a way so that i may get the account name which that id field refers to in 
the account master?
for example i am getting something like this in the selection scroll bar:
5 2012-05-08 1 where 5 is the Account_Master's id field. What if i want the 
Account at id 5 to be shown in the sqlform.factory instead?
 
Also i think it neccessary to mention that I am using sqlform.factory 
because i am seeking some parameters from users and i am storing those 
parameters in session object to generate some report based on those.

   



[web2py] Re: nginx uwsgi error 502 bad gate way

2012-05-20 Thread Deidre
Can I just say thank you to Gour for his suggestion of setting up a virtual 
machine and then the same linux as on my VPS. This approach had not 
occurred to me, but is such a good solution to allowing me to experiment.

Peter



On Thursday, May 17, 2012 12:06:12 AM UTC+1, Lewis wrote:
>
> Guys, I have followed the cookbook, the posts here, and a posting at 
> stackoverflow.
>
> I am getting error 502 bad gateway.  My stuff looks like everyone else's 
> but there are deeper layers of indirection in uwsgi itself and nginx.  I 
> have several uwsgi sym links in /etc/init.dIt is not clear which is the 
> "real" one and how to invoke it.
>
> Here is the error from the nginx log.  I guess I interpret this to mean 
> that nginx can't find uwsgi:
>
> 2012/05/16 22:53:29 [error] 2460#0: *1 connect() failed (111: Connection 
> refused) while connecting to upstream, client: 76.104.195.84, server: 
> www.lewcl.com, request: "GET / HTTP/1.1", upstream: "uwsgi://
> 127.0.0.1:9001", host: "www.lewcl.com"
>
> I have no clue what to do.
>
> Guys, I think that python and web2py have a profoundly serious problem 
> with config.  Documentation is often wrong--a single punctuation mark, 
> directory or option being off means it won't work.  If we have that in our 
> Python code it won't run, but we have great traceback and debugging tools 
> to tell us exactly where the error is and often what the error is. But when 
> one of 5 or 6 text files scattered across the file system is wrong, all we 
> find out is that it won't run.  There are no diagnostics (or very course 
> ones like "error").  I'd like to work with some people in the community to 
> redo a lot of the guides and get them to be accurate.
>
> I don't think script files are much of a solution (except as a way to 
> document something that once worked on some arbitrary system).  Running an 
> arbitrary script file blindly can do serious harm to your environment.   
> Script files are not fully debugged and recoverable setup programs. 
>  "Setup" is one of the hardest things to do right.  It is not a throw-away 
> task to be done at the end of the project.
>


[web2py] Re: response.menu issue

2012-05-20 Thread Anthony
By calling the .xml() method, you are serializing the A() helper before it 
gets written to the response body, so the template engine will escape the 
string instead of inserting it as HTML. To avoid that, wrap the whole thing 
in XML():

{{=XML('|'.join(A(_[0],_href=_[2]).xml() for _ in response.menu))}}

See http://web2py.com/books/default/chapter/29/5#XML.

Anthony

On Sunday, May 20, 2012 4:14:58 AM UTC-4, Frank wrote:
>
> hi,all, 
> hope get help from you, 
>
> {{=('|'.join(A(_[0],_href=_[2]).xml() for _ in response.menu))}} suppose 
> to be 
> several links on webpage, but it appear to be string on my app, how to 
> change it? 
>
> thanks, 
>
> Frank 
>
>

[web2py] Passing a SELECT

2012-05-20 Thread Madu

Hello,

I'm trying to pass a SELECT as follows:
def showToolEntries():
if request.args(0) in ToolsDB.tables:
return dict(entries=SELECT("Select from list", operationalToolsDB().
select(ToolsDB[request.args(0)].serial_number)))

I have a DB called ToolsDB and I have several tables in that. Each table 
has an field called 'serial_number'. I want to pass a SELECT to the html 
with the tools in the selected table.

> For example, if I have two rows in my table, say, tool_1 and tool_2, the 
> resulting drop down will have only one entry which says *
> TABLE1.serial_numbertool_1tool_2*. Both tools are in the same row. I 
> can't understand why the two tools are shown in one entry in the drop down 
> select. So a SELECT drop down is actually passed but the entries are not 
> passed correctly.


However when I do:
def showToolEntries():
if request.args(0) inToolsDB.tables:
return dict(entries=,ToolsDB().select(operationalToolsDB[request.
args(0)].serial_number))

I can properly see the tool entries correctly printed out as:

> TABLE1.serial_number
> tool_1
> tool_2


Could somebody please help me with this.
Thank you.

Cheers. 


[web2py] Re: Format representation in foreign table.

2012-05-20 Thread Anthony

>
> db.define_table('Account_Master',Field('Account',requires=IS_NOT_EMPTY()),Field('Sewadari1'),Field('Mb1'),Field('Sewadari2'),Field('Mb2'),Field('City'),Field('District'),Field('State'),Field('Email'),Field('Remark'),format='%(Account)s
>  
> %(State)s ')
>
> db.define_table('Transaction_Master',Field('Account',db.Account_Master,requires=IS_IN_DB(db,'Account_Master.id',
>  
> '%(Account)s %(State)s',zero=T('choose 
> one'))),Field('Exam_Date','date'),Field('Entry_Date','date',default=request.now),Field('Form_1','upload'),Field('Form_1_Name'),Field('Schoolwise_Form','upload'),Field('Schoolwise_Form_Name'),format='%(Account)s
>  
> %(Exam_Date)s')
>
> When i try to represent the account field of Transaction_Master table in 
> sqlform.factory as:
>  form=SQLFORM.factory(Field('TID',requires=IS_IN_DB(db,
> db.Transaction_Master.id,'%(Account)s %(Exam_Date)s %(id)s')))
>
> I am getting the id field of account in the sqlform.factory form. Is there 
> a way so that i may get the account name which that id field refers to in 
> the account master?
>

Your IS_IN_DB validator refers to '%(Account)s', but the Account field in 
the Transaction_Master table is a reference field and therefore just stores 
integers (i.e., record ID's), so that's what you're getting -- the format 
does not propagate from the db.Account_Master table to the 
db.Transaction_Master table. Instead, though, the format argument to 
IS_IN_DB can be a callable (e.g., a lambda) that takes a record and returns 
the representation you want. So, try:

IS_IN_DB(db, db.Transaction_Master.id,
lambda r: '%s %s %s' % (db.Account_Master[r.Account].Account, r.
Exam_Date, r.id))

Note, the format argument to define_table() can also be a callable.

Anthony



[web2py] Re: response.menu issue

2012-05-20 Thread Frank
Anthony,
thanks, 

Frank

On Sunday, May 20, 2012 8:54:49 PM UTC+8, Anthony wrote:
>
> By calling the .xml() method, you are serializing the A() helper before it 
> gets written to the response body, so the template engine will escape the 
> string instead of inserting it as HTML. To avoid that, wrap the whole thing 
> in XML():
>
> {{=XML('|'.join(A(_[0],_href=_[2]).xml() for _ in response.menu))}}
>
> See http://web2py.com/books/default/chapter/29/5#XML.
>
> Anthony
>
> On Sunday, May 20, 2012 4:14:58 AM UTC-4, Frank wrote:
>>
>> hi,all, 
>> hope get help from you, 
>>
>> {{=('|'.join(A(_[0],_href=_[2]).xml() for _ in response.menu))}} suppose 
>> to be 
>> several links on webpage, but it appear to be string on my app, how to 
>> change it? 
>>
>> thanks, 
>>
>> Frank 
>>
>>

[web2py] Re: Passing a SELECT

2012-05-20 Thread Anthony

>
> I'm trying to pass a SELECT as follows:
> def showToolEntries():
> if request.args(0) in ToolsDB.tables:
> return dict(entries=SELECT("Select from list", operationalToolsDB
> ().select(ToolsDB[request.args(0)].serial_number)))
>

SELECT() takes either a list or a set of positional arguments. Since you 
passed "Select from list" as the first argument, it takes the result of 
your db select (which is a Rows object) as a positional argument and puts 
it all in a single  element. The Rows object is serialized into an 
HTML table, which apparently the browser compresses to a single row. 
Instead, try something like this:

SELECT("Select from list",
 *[r.serial_number for r in ToolsDB().select(ToolsDB[request.args(0)].
serial_number)])

Anthony


[web2py] Re: nginx uwsgi error 502 bad gate way

2012-05-20 Thread Gour
On Sun, 20 May 2012 05:38:35 -0700 (PDT)
Deidre  wrote:

> Can I just say thank you to Gour for his suggestion of setting up a
> virtual machine and then the same linux as on my VPS. 

I'm glad it was helpful to you. :-)

> This approach had not occurred to me, but is such a good solution to
> allowing me to experiment.

Well, it is always easier to troubleshoot when the environment is (more)
under our control. ;)


Sincerely,
Gour


-- 
For him who has conquered the mind, the mind is the best of 
friends; but for one who has failed to do so, his mind will 
remain the greatest enemy.

http://atmarama.net | Hlapicina (Croatia) | GPG: 52B5C810


signature.asc
Description: PGP signature


[web2py] Re: What to expect in web2py 2.0

2012-05-20 Thread nick name
On Saturday, May 19, 2012 4:10:13 PM UTC-4, Massimo Di Pierro wrote:
>
> Basically the same features we have in trunk now. Just lots of bug fixes 
> compared to latest table.
> We will also have full versining, geo api in db, possibly better support 
> for mongodb and sybase, and a new welcome app based on bootstrap (and this 
> is holding up more than anything else).
>

Massimo, did you notice Issue 
801: 
Corrupt downloads when output generated in parts (under rocket) ?

I think at the very least, rocket.py should be patched to abort these 
connections (rather than silently truncate). The small change I suggested 
in https://groups.google.com/d/msg/web2py/1_b63bhBeQs/sYFbXNJL8D4J could 
probably be modified to just close the connection and avoid the download 
corruption, but in the same thread, Phyo Arkar mentions that he has upload 
corruptions too -- which I haven't been able to reproduce.




[web2py] file upload field dissapears if form is not valid

2012-05-20 Thread Sebastian E. Ovide
Hi All,

if a form has some file upload fields, and some field validation then when
the form is submitted with some field not valid (such as mandatory field
not filled up), then the form will display the usual red message (as it
should), keeping all the values of the form as entered by the user except
for the files upload. Therefore the user is *forced* to upload the files
again...

Is it working as designed ?

thanks

-- 
Sebastian E. Ovide


[web2py] HTSQL & web2py

2012-05-20 Thread Gour
Hello,

some time ago we were considering to use HTSQL (http://htsql.org/) in
our project to make it easier for end-users to perform complex queries
on their database easily, but the barrier was HTSQL's licensing.

Now we see that they did change a license and noticed: "...We provide
meta-data adapters for Django and SQLAlchemy."
(http://htsql.org/doc/overview.html), so the question arises what do you
think about having adapter for web2py?


Sincerely,
Gour


-- 
The intricacies of action are very hard to understand. 
Therefore one should know properly what action is, 
what forbidden action is, and what inaction is.

http://atmarama.net | Hlapicina (Croatia) | GPG: 52B5C810


signature.asc
Description: PGP signature


[web2py] Re: Passing a SELECT

2012-05-20 Thread Madu

Thank you very much Anthony for your detailed explanation. I didn't realize 
the db select returns a Rows object.
Your solution worked!

Thank you.


On Sunday, May 20, 2012 11:03:33 PM UTC+9, Anthony wrote:
>
> I'm trying to pass a SELECT as follows:
>> def showToolEntries():
>> if request.args(0) in ToolsDB.tables:
>> return dict(entries=SELECT("Select from list", operationalToolsDB
>> ().select(ToolsDB[request.args(0)].serial_number)))
>>
>
> SELECT() takes either a list or a set of positional arguments. Since you 
> passed "Select from list" as the first argument, it takes the result of 
> your db select (which is a Rows object) as a positional argument and puts 
> it all in a single  element. The Rows object is serialized into an 
> HTML table, which apparently the browser compresses to a single row. 
> Instead, try something like this:
>
> SELECT("Select from list",
>  *[r.serial_number for r in ToolsDB().select(ToolsDB[request.args(0)].
> serial_number)])
>
> Anthony
>


[web2py] good read about python

2012-05-20 Thread Massimo Di Pierro
http://satyajit.ranjeev.in/2012/05/17/python-a-few-things-to-remember.html


[web2py] Re: Contract work to build a bridge between a C# system and a broker API, using Web2py

2012-05-20 Thread Massimo Di Pierro
very interesting.

On Sunday, 20 May 2012 02:39:52 UTC-5, vlc wrote:
>
> I'd like to have a simple connector/bridge built between NinjaTrader 7 
> (NT7) and CityIndex API (CIAPI).  Normal practice would probably be to 
> build it in C# but I'd prefer it in Python, using web2py if possible.
> There is an incomplete Python version of the CIAPI library at 
> http://code.google.com/p/ciapi/
> Docs on the NT7 side are at... 
> http://www.ninjatrader.com/support/helpGuides/nt7/dll_interface.htm?zoom_highlightsub=ntdirect
> and there are various URLs for the CityIndex API docs but you could start 
> at: https://ciapipreprod.cityindextest9.co.uk/ciapi.docs/ and at: 
> https://ciapipreprod.cityindextest9.co.uk/ciapi.docs/#content.concepts
> The solution may involve using a local FIX server, such as the one 
> available at http://www.quickfixengine.org/
>
> The purpose of this bridge is to allow trades to be placed using a UI 
> other than the one provided by CityIndex; I would prefer to use NT7 as my 
> UI.
> I've tried to keep this message as brief as possible.  More detail 
> available upon request.
> I estimate the work would take 7 to 10 days.
>
>

[web2py] Re: What to expect in web2py 2.0

2012-05-20 Thread Massimo Di Pierro
I am waiting to see if Tim wants to work on this (he is the rocket man) as 
I'd rather not fork it.

Massimo

On Sunday, 20 May 2012 09:15:19 UTC-5, nick name wrote:
>
> On Saturday, May 19, 2012 4:10:13 PM UTC-4, Massimo Di Pierro wrote:
>>
>> Basically the same features we have in trunk now. Just lots of bug fixes 
>> compared to latest table.
>> We will also have full versining, geo api in db, possibly better support 
>> for mongodb and sybase, and a new welcome app based on bootstrap (and this 
>> is holding up more than anything else).
>>
>
> Massimo, did you notice Issue 
> 801: 
> Corrupt downloads when output generated in parts (under rocket) ?
>
> I think at the very least, rocket.py should be patched to abort these 
> connections (rather than silently truncate). The small change I suggested 
> in https://groups.google.com/d/msg/web2py/1_b63bhBeQs/sYFbXNJL8D4J could 
> probably be modified to just close the connection and avoid the download 
> corruption, but in the same thread, Phyo Arkar mentions that he has upload 
> corruptions too -- which I haven't been able to reproduce.
>
>
>

[web2py] Re: file upload field dissapears if form is not valid

2012-05-20 Thread Anthony
On Sunday, May 20, 2012 10:22:02 AM UTC-4, sebastian wrote:
>
> Hi All,
>
> if a form has some file upload fields, and some field validation then when 
> the form is submitted with some field not valid (such as mandatory field 
> not filled up), then the form will display the usual red message (as it 
> should), keeping all the values of the form as entered by the user except 
> for the files upload. Therefore the user is *forced* to upload the files 
> again...
>
> Is it working as designed ?
>

For security reasons, the browser will not allow the reference to the file 
on the user's filesystem to be retained in the form upload widget, so the 
user will have to re-select the file for upload. Alternatively, web2py 
could keep the originally uploaded file on the server and simply not 
require the user to re-select and re-upload the file, but that could get a 
bit complicated to implement (e.g., what happens to the orphaned file if 
there is no subsequent successful submission?).

Anthony


[web2py] Re: file upload field dissapears if form is not valid

2012-05-20 Thread Massimo Di Pierro
Yes. We could change this and cache the file. Open a ticket as suggestion 
for improvement. Anyway, this needs to be thought true has it may have some 
security implications.

On Sunday, 20 May 2012 09:22:02 UTC-5, sebastian wrote:
>
> Hi All,
>
> if a form has some file upload fields, and some field validation then when 
> the form is submitted with some field not valid (such as mandatory field 
> not filled up), then the form will display the usual red message (as it 
> should), keeping all the values of the form as entered by the user except 
> for the files upload. Therefore the user is *forced* to upload the files 
> again...
>
> Is it working as designed ?
>
> thanks
>
> -- 
> Sebastian E. Ovide
>
>
>
>  

[web2py] Re: HTSQL & web2py

2012-05-20 Thread Massimo Di Pierro
It would be a good idea. I am not sure how easy or difficult it would be. I 
will take a closer look.

On Sunday, 20 May 2012 09:35:37 UTC-5, Gour wrote:
>
> Hello, 
>
> some time ago we were considering to use HTSQL (http://htsql.org/) in 
> our project to make it easier for end-users to perform complex queries 
> on their database easily, but the barrier was HTSQL's licensing. 
>
> Now we see that they did change a license and noticed: "...We provide 
> meta-data adapters for Django and SQLAlchemy." 
> (http://htsql.org/doc/overview.html), so the question arises what do you 
> think about having adapter for web2py? 
>
>
> Sincerely, 
> Gour 
>
>
> -- 
> The intricacies of action are very hard to understand. 
> Therefore one should know properly what action is, 
> what forbidden action is, and what inaction is. 
>
> http://atmarama.net | Hlapicina (Croatia) | GPG: 52B5C810 
>


Re: [web2py] good read about python

2012-05-20 Thread Bruno Rocha
(func if x else otherfunc)(*args)

This is a nice tip, I can remove a lot of if's using this.

Thanks for sharing.

http://zerp.ly/rochacbruno
Em 20/05/2012 11:48, "Massimo Di Pierro" 
escreveu:

> http://satyajit.ranjeev.in/2012/05/17/python-a-few-things-to-remember.html
>


Re: [web2py] Re: SQLFORM.grid import

2012-05-20 Thread Jonathan Lundell
On May 19, 2012, at 1:06 PM, Massimo Di Pierro wrote:
> I'd take a patch. There may be some issues I have not though of.

I took a look at this, hoping it'd be a quick Sunday morning project. But I 
found myself in over my head, and not sure how to integrate an html upload 
control with the existing code (jQuery buttons and such).

I think it should be straightforward, but not for me...


> 
> On Saturday, 19 May 2012 09:27:53 UTC-5, Jonathan Lundell wrote:
> It'd be convenient, I think, to have an SQLFORM.grid import button that 
> imported what the export button exports (csv). Granted that the admin 
> interface can be used for this, but for a couple of my tables it'd be handy 
> to be able to enable an import button if, say, the table is empty.




[web2py] Editor broken in trunk?

2012-05-20 Thread Larry Weinberg
My previous web2py installation works fine

I grabbed the trunk and out of the box the editor is unable to save.  I can 
edit text, but there is no way to save the text now.  Also, the menu bar is 
not visible for it.

Is this a known problem or do I have some python installation problem?




[web2py] Re: Format representation in foreign table.

2012-05-20 Thread rahulserver
Thanks Anthony! 

I did as u said but now i get the following error:
 'NoneType' object has no attribute 
'Account'

Here is the line which was found erroraneous(in pink):

def viewreport():
form=SQLFORM.factory(Field('TID',requires=IS_IN_DB(db, 
db.Transaction_Master.id,
lambda r: '%s %s %s' % (db.Account_Master[r.Account].Account, r.Exam_Date, 
r.id))


))

With Regards,
rahulserver.

On Sunday, May 20, 2012 6:01:14 PM UTC+5:30, rahulserver wrote:
>
> I have two tables:
> db.define_table('Account_Master',Field('Account',requires=IS_NOT_EMPTY()),Field('Sewadari1'),Field('Mb1'),Field('Sewadari2'),Field('Mb2'),Field('City'),Field('District'),Field('State'),Field('Email'),Field('Remark'),format='%(Account)s
>  
> %(State)s ')
>
> db.define_table('Transaction_Master',Field('Account',db.Account_Master,requires=IS_IN_DB(db,'Account_Master.id',
>  
> '%(Account)s %(State)s',zero=T('choose 
> one'))),Field('Exam_Date','date'),Field('Entry_Date','date',default=request.now),Field('Form_1','upload'),Field('Form_1_Name'),Field('Schoolwise_Form','upload'),Field('Schoolwise_Form_Name'),format='%(Account)s
>  
> %(Exam_Date)s')
>
> When i try to represent the account field of Transaction_Master table in 
> sqlform.factory as:
>  form=SQLFORM.factory(Field('TID',requires=IS_IN_DB(db,
> db.Transaction_Master.id,'%(Account)s %(Exam_Date)s %(id)s')))
>
> I am getting the id field of account in the sqlform.factory form. Is there 
> a way so that i may get the account name which that id field refers to in 
> the account master?
> for example i am getting something like this in the selection scroll bar:
> 5 2012-05-08 1 where 5 is the Account_Master's id field. What if i want 
> the Account at id 5 to be shown in the sqlform.factory instead?
>  
> Also i think it neccessary to mention that I am using sqlform.factory 
> because i am seeking some parameters from users and i am storing those 
> parameters in session object to generate some report based on those.
>
>
>
>

[web2py] Computed Column specification based on child table attributes in web2py

2012-05-20 Thread rahulserver
I have 2 tables:
db.define_table('Transaction_Master',Field('Account',db.Account_Master,requires=IS_IN_DB(db,'Account_Master.id',
 
'%(Account)s %(State)s',zero=T('choose 
one'))),Field('Exam_Date','date'),Field('Entry_Date','date',default=request.now),Field('Form_1','upload'),Field('Form_1_Name'),
Field('Schoolwise_Form','upload'),Field('Schoolwise_Form_Name'),format='%(Account)s
 
%(Exam_Date)s')

and:
db.define_table('Transactions',Field('TID',db.Transaction_Master),Field('School'),Field('Number_of_students','integer'))

The db.Transactions table will be populated by the excel sheet in 
Transaction_Master.Schoolwise_Form which contains the list of school names 
and number of students. I wish to add a computed column in the first 
table(virtual) which will simply sum up the number of students in 
Transactions referenced by Transaction_Master.tid. How do i do it?




[web2py] Re: Is there anyone who running web2py application on Redhat openshift?

2012-05-20 Thread Changju
Hi JungHyun.
I have one question for you.
I don't know about Openshift but I want to know why you chose Openshift 
other than Pythonanywhere or Fluxflex which are all free for low traffic.

Thanks,
Changju

On Saturday, May 19, 2012 7:44:31 PM UTC+9, JungHyun Kim wrote:
>
> Andrew!!
>
> It works !!!
>
> Two things were keys.
>
> 1. setting gluon module in "libs" directory
> 2. and making environment to see that module.
>
> Thank you for your help! :)
>
>
> 2012년 5월 19일 토요일 오후 12시 14분 5초 UTC+9, Andrew 님의 말:
>>
>> JungHyun,
>>
>>
>> Here's my project structure with application file attached- Let me know 
>> if this helps.
>>
>> data/
>> .
>> ..
>> 
>> libs/
>> gluon (moved from web2py dir)
>>
>> wsgi/
>> application - Attaching this to post
>> web2py/
>>   ..std web2py minus gluon dir moved to libs..
>>
>> .openshift/ (nothing modified)
>>  action_hooks
>>  cron
>>  markers
>>
>> On Tuesday, May 15, 2012 2:55:07 AM UTC-5, JungHyun Kim wrote:
>>>
>>> Hello. I'm now trying to use redhat openshift.
>>>
>>> I am struggling access database - mysql-5.1 - which is set via openshift 
>>> cartridge.
>>> I got admin user(admin), password and database name(we2py).
>>> So I modified database setting in models/db.py 
>>>
>>> as
>>>
>>> db = DAL('mysql://admin:passw...@web2py-codingday.rhcloud.com/web2py')
>>>
>>> But web2py application can't connect to mysql.
>>>
>>> OperationalError: (2003, "Can't connect to MySQL server on '
>>> web2py-codingday.rhcloud.com' (111)")
>>>
>>> I think I couldn't understand enough. I am a noob for both web2py and 
>>> openshift.
>>>
>>> How can I make web2py connect to database right?
>>>
>>> Thank you.
>>>
>>>
>>>

[web2py] Re: Editor broken in trunk?

2012-05-20 Thread Massimo Di Pierro
known problem. can you save by clicking the button?

On Sunday, 20 May 2012 10:46:42 UTC-5, Larry Weinberg wrote:
>
> My previous web2py installation works fine
>
> I grabbed the trunk and out of the box the editor is unable to save.  I 
> can edit text, but there is no way to save the text now.  Also, the menu 
> bar is not visible for it.
>
> Is this a known problem or do I have some python installation problem?
>
>
>

[web2py] Re: Pass multiple arguments to URL through javascript

2012-05-20 Thread Ashraf Mansour
I think this is an important topic, And needs to be highlighted in the book 
and by example.

On Saturday, December 3, 2011 7:10:59 PM UTC+3, Vineet wrote:
>
> I referred to the below-mentioned thread (but could not reply to it).
>
>
> https://groups.google.com/group/web2py/browse_thread/thread/61d57e887e42aee8/c3dd5cd43b9d5527?lnk=gst&q=URL+javascript+variable
>
> My question is ---
> If I have two javascript variables, which are to be passed to a
> controller through URL helper as under --
>
> [CODE]
> 
>   
>  var param1 = 'value1' ;
>  var param2 = 'value2'
>
>   "{{URL(r=request,c='static',f='action')}}/"+param1¶m2
> that did not work
>   "{{URL(r=request,c='static',f='action')}}/"+(param1,param2)
> didn't work either.
>  .
>  
> [/CODE]
>
> How do I code it?
>
>
> Thanks,
> Vineet
>
>

Re: [web2py] Re: Editor broken in trunk?

2012-05-20 Thread Mariano Reingart
You can use the previous editor by changing the 10th line in
web2py/applications/admin/models/0.py to

TEXT_EDITOR = 'edit_area' or 'amy'

The keybinding problem seems an issue of ACE, I'll take a look ASAP
In which OS / Browser has happen the problem?

Best regards

Mariano Reingart
http://www.sistemasagiles.com.ar
http://reingart.blogspot.com


On Sun, May 20, 2012 at 1:34 PM, Massimo Di Pierro
 wrote:
> known problem. can you save by clicking the button?
>
>
> On Sunday, 20 May 2012 10:46:42 UTC-5, Larry Weinberg wrote:
>>
>> My previous web2py installation works fine
>>
>> I grabbed the trunk and out of the box the editor is unable to save.  I
>> can edit text, but there is no way to save the text now.  Also, the menu bar
>> is not visible for it.
>>
>> Is this a known problem or do I have some python installation problem?
>>
>>
>


[web2py] Re: Pass multiple arguments to URL through javascript

2012-05-20 Thread Ashraf Mansour
I tried this



and it did not work.:)

what is the right way of doing it?

On Saturday, December 3, 2011 7:37:58 PM UTC+3, Anthony wrote:
>
> 

[web2py] plugin_dieromail

2012-05-20 Thread Alan Etkin
A new web2py plugin that features an interface for DineroMail IPNv2 
(payment notification and detailed transaction reports).

plugin_dineromail 

DineroMail is a third party online money transfer and payments system 
currently for Argentina, Brasil, Chile, Colombia and México.

The project has a development installer version available for download 
here.
 
The source code is released under 
AGPLv3
.


Re: [web2py] Re: file upload field dissapears if form is not valid

2012-05-20 Thread Sebastian E. Ovide
done http://code.google.com/p/web2py/issues/detail?id=811

On Sun, May 20, 2012 at 4:03 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> Yes. We could change this and cache the file. Open a ticket as suggestion
> for improvement. Anyway, this needs to be thought true has it may have some
> security implications.
>
>
> On Sunday, 20 May 2012 09:22:02 UTC-5, sebastian wrote:
>>
>> Hi All,
>>
>> if a form has some file upload fields, and some field validation then
>> when the form is submitted with some field not valid (such as mandatory
>> field not filled up), then the form will display the usual red message (as
>> it should), keeping all the values of the form as entered by the user
>> except for the files upload. Therefore the user is *forced* to upload
>> the files again...
>>
>> Is it working as designed ?
>>
>> thanks
>>
>> --
>> Sebastian E. Ovide
>>
>>
>>
>>


Re: [web2py] Re: Pass multiple arguments to URL through javascript

2012-05-20 Thread Bruce Wade
{{=URL('controller','action', args=[arg1, arg2])}}
On May 20, 2012 10:18 AM, "Ashraf Mansour"  wrote:

> I tried this
>
> 
>
> and it did not work.:)
>
> what is the right way of doing it?
>
> On Saturday, December 3, 2011 7:37:58 PM UTC+3, Anthony wrote:
>>
>> 

[web2py] Re: Editor broken in trunk?

2012-05-20 Thread Larry Weinberg
I cannot save with the button.
I tried Safari and Chrome.  Both had the problem.

On Sunday, May 20, 2012 8:46:42 AM UTC-7, Larry Weinberg wrote:
>
> My previous web2py installation works fine
>
> I grabbed the trunk and out of the box the editor is unable to save.  I 
> can edit text, but there is no way to save the text now.  Also, the menu 
> bar is not visible for it.
>
> Is this a known problem or do I have some python installation problem?
>
>
>

[web2py] Re: Pass multiple arguments to URL through javascript

2012-05-20 Thread Anthony
On Sunday, May 20, 2012 1:18:44 PM UTC-4, Ashraf Mansour wrote:
>
> I tried this
>
> 
>
> and it did not work.:)
>
> what is the right way of doing it?
>

A() doesn't produce a URL -- it produces an anchor tag (i.e., ...), to which you are then appending "/param1/param2", 
which obviously doesn't work.

What are you trying to do? Are param1 and param2 known on the server side? 
If so, add them as args to the URL() function. If they are determined on 
the client side, then you'll need to use Javascript to generate the URL on 
the client.

Anthony


[web2py] Re: Editor broken in trunk?

2012-05-20 Thread Massimo Di Pierro
I have the same problem. I use chrome.

On Sunday, 20 May 2012 13:09:19 UTC-5, Larry Weinberg wrote:
>
> I cannot save with the button.
> I tried Safari and Chrome.  Both had the problem.
>
> On Sunday, May 20, 2012 8:46:42 AM UTC-7, Larry Weinberg wrote:
>>
>> My previous web2py installation works fine
>>
>> I grabbed the trunk and out of the box the editor is unable to save.  I 
>> can edit text, but there is no way to save the text now.  Also, the menu 
>> bar is not visible for it.
>>
>> Is this a known problem or do I have some python installation problem?
>>
>>
>>

[web2py] Re: Format representation in foreign table.

2012-05-20 Thread Anthony
On Sunday, May 20, 2012 11:49:41 AM UTC-4, rahulserver wrote:
>
> Thanks Anthony! 
>
> I did as u said but now i get the following error:
>  'NoneType' object has no attribute 
> 'Account'
>
> Here is the line which was found erroraneous(in pink):
>
> def viewreport():
> form=SQLFORM.factory(Field('TID',requires=IS_IN_DB(db, 
> db.Transaction_Master.id,
> lambda r: '%s %s %s' % (db.Account_Master[r.Account].Account, 
> r.Exam_Date, r.id))
>
>
> ))
>
> With Regards,
> rahulserver.
>

Are there records in db.Account_Master and db.Transaction_Master, and do 
all values in db.Transaction_Master.Account reference existing records in 
db.Account_Master? If not, you could add a conditional:

IS_IN_DB(db, db.Transaction_Master.id,
lambda r: '%s %s %s' % \
(db.Account_Master[r.Account].Account if db.Account_Master[r.Account] 
else '',
r.Exam_Date, r.id))

Anthony


[web2py] Re: Little problem with scheduler_task - has no signature Fields

2012-05-20 Thread szimszon
There are users they can  trigger scheduled tasks and I need to audit it. 
I'll try what you say. And report back.

2012. május 18., péntek 17:56:19 UTC+2 időpontban Niphlod a következőt írta:
>
> you can put them on like in every table, and then prevent the scheduler 
> migrating the table setting migrate=False in its call.
> There should be no problems on that, but a big problem arises : the 
> scheduler_task table will likely to have multiple copies of the same task 
> (auditing works in that way, setting to "is_active" only the last version 
> of the record but keeping the entire history) and will try to execute all 
> of them.
>
> anyway, why do you need to audit the task table ?
>
> Il giorno venerdì 18 maggio 2012 10:43:38 UTC+2, szimszon ha scritto:
>>
>> Hi!
>>
>> I wonder if somebody could help me.
>>
>> I have to audit scheduler_task 
>> db.scheduler_task._enable_record_versioning() works but scheduler_task have 
>> no Created On, By and Modified On, By (is_active) Fields :(
>>
>> Can we put this Fields in it?
>>
>

[web2py] Re: Pass multiple arguments to URL through javascript

2012-05-20 Thread Ashraf Mansour
thanks for the immediate reply.

param1 and param2 are determined on the client side.

how can it be generated by javascript?


On Sunday, May 20, 2012 10:05:10 PM UTC+3, Anthony wrote:
>
> On Sunday, May 20, 2012 1:18:44 PM UTC-4, Ashraf Mansour wrote:
>>
>> I tried this
>>
>> 
>>
>> and it did not work.:)
>>
>> what is the right way of doing it?
>>
>
> A() doesn't produce a URL -- it produces an anchor tag (i.e.,  href="...">...), to which you are then appending "/param1/param2", 
> which obviously doesn't work.
>
> What are you trying to do? Are param1 and param2 known on the server side? 
> If so, add them as args to the URL() function. If they are determined on 
> the client side, then you'll need to use Javascript to generate the URL on 
> the client.
>
> Anthony
>


Re: [web2py] Re: Pass multiple arguments to URL through javascript

2012-05-20 Thread Ashraf Mansour
thanks for the immediate reply.

param1 and param2 are determined on the client side.

 

how can it be generated by javascript?

>
>>>  

[web2py] Re: Little problem with scheduler_task - has no signature Fields

2012-05-20 Thread Massimo Di Pierro
Please open a ticket about this. We can add options to add fields to 
scheduler tables.

On Friday, 18 May 2012 03:43:38 UTC-5, szimszon wrote:
>
> Hi!
>
> I wonder if somebody could help me.
>
> I have to audit scheduler_task 
> db.scheduler_task._enable_record_versioning() works but scheduler_task have 
> no Created On, By and Modified On, By (is_active) Fields :(
>
> Can we put this Fields in it?
>


[web2py] Re: Pass multiple arguments to URL through javascript

2012-05-20 Thread Anthony


On Sunday, May 20, 2012 3:43:38 PM UTC-4, Ashraf Mansour wrote:
>
> thanks for the immediate reply.
>
> param1 and param2 are determined on the client side.
>
> how can it be generated by javascript?
>
>
It depends. Here's one example:


jQuery(function() {
  var param1 = 'hello'
  var param2 = 'world'
  jQuery('a#mylink').attr('href', '{{=URL("action")}}' + '/' + param1 + '/' 
+ param2);
});


{{=A('...', _href='', _id='mylink')}}

When the page is loaded, the href of the mylink anchor tag will be replaced 
with the "action" URL along with the values of param1 and param2 appended. 
Of course, you'll need some way to set the values of param1 and param2, and 
there may be some other event that should trigger the replacement -- it 
depends what you're trying to do.

Anthony



Re: [web2py] Re: Pass multiple arguments to URL through javascript

2012-05-20 Thread Bruce Wade
Why would you do the code like that?? [?]
Updated:

jQuery(function() {
  var param1 = 'hello'
  var param2 = 'world'
  jQuery('a#mylink').attr('href', '{{=URL("action", args=["' + param1 +
'","' + param2 + '"])}}');
});


{{=A('...', _href='', _id='mylink')}}


On Sun, May 20, 2012 at 4:36 PM, Anthony  wrote:

>
>
> On Sunday, May 20, 2012 3:43:38 PM UTC-4, Ashraf Mansour wrote:
>>
>> thanks for the immediate reply.
>>
>> param1 and param2 are determined on the client side.
>>
>> how can it be generated by javascript?
>>
>>
> It depends. Here's one example:
>
> 
> jQuery(function() {
>   var param1 = 'hello'
>   var param2 = 'world'
>   jQuery('a#mylink').attr('href', '{{=URL("action")}}' + '/' + param1 +
> '/' + param2);
> });
> 
>
> {{=A('...', _href='', _id='mylink')}}
>
> When the page is loaded, the href of the mylink anchor tag will be
> replaced with the "action" URL along with the values of param1 and param2
> appended. Of course, you'll need some way to set the values of param1 and
> param2, and there may be some other event that should trigger the
> replacement -- it depends what you're trying to do.
>
> 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
<<35E.gif>>

Re: [web2py] Re: Pass multiple arguments to URL through javascript

2012-05-20 Thread Anthony
He said param1 and param2 are determined on the client side -- which means 
they cannot be set on the server side by web2py. Of course, I don't know 
what he's actually doing on the client side, so this exact code may or may 
not be relevant. Do you have an alternative suggestion?

Anthony

On Sunday, May 20, 2012 7:57:10 PM UTC-4, Bruce Wade wrote:
>
> Why would you do the code like that?? 
> Updated: 
> 
> jQuery(function() {
>   var param1 = 'hello'
>   var param2 = 'world'
>   jQuery('a#mylink').attr('href', '{{=URL("action", args=["' + param1 + 
> '","' + param2 + '"])}}');
> });
> 
>
> {{=A('...', _href='', _id='mylink')}}
>
>
> On Sun, May 20, 2012 at 4:36 PM, Anthony  wrote:
>
>>
>>
>> On Sunday, May 20, 2012 3:43:38 PM UTC-4, Ashraf Mansour wrote:
>>>
>>> thanks for the immediate reply.
>>>
>>> param1 and param2 are determined on the client side.
>>>
>>> how can it be generated by javascript?
>>>
>>>
>> It depends. Here's one example:
>>
>> 
>> jQuery(function() {
>>   var param1 = 'hello'
>>   var param2 = 'world'
>>   jQuery('a#mylink').attr('href', '{{=URL("action")}}' + '/' + param1 + 
>> '/' + param2);
>> });
>> 
>>
>> {{=A('...', _href='', _id='mylink')}}
>>
>> When the page is loaded, the href of the mylink anchor tag will be 
>> replaced with the "action" URL along with the values of param1 and param2 
>> appended. Of course, you'll need some way to set the values of param1 and 
>> param2, and there may be some other event that should trigger the 
>> replacement -- it depends what you're trying to do.
>>
>> 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
>
>

Re: [web2py] Re: Pass multiple arguments to URL through javascript

2012-05-20 Thread Bruce Wade
Well honestly if it was a dynamic link I wouldn't even use URL as good
style of JS programming is putting the code in a .js if this is the case
then the web2py parser cannot even access the URL to parse it. (At least I
have never been successful with that process.)

If they are getting the params at a later time and in a js file there is no
need in using the URL just use url = '/path/' + param + '/' + param; The
only problem with this is if he changes the path, however if he changes the
path he would be required to update URL() anyways.

I have fell into the trap on trying to rely on the helpers to much myself
in the past. Some places in your code you shouldn't use them. Trying to use
them for everything kind of forces you to change your logic to bend around
web2py instead of having web2py work with your logic. Also whenever you use
URL instead of the direct url='/path' the framework is forced to do more
function calls, in some situations like this one it isn't really worth
having the extra function call and it is actually more typing :D

On Sun, May 20, 2012 at 5:19 PM, Anthony  wrote:

> He said param1 and param2 are determined on the client side -- which means
> they cannot be set on the server side by web2py. Of course, I don't know
> what he's actually doing on the client side, so this exact code may or may
> not be relevant. Do you have an alternative suggestion?
>
> Anthony
>
> On Sunday, May 20, 2012 7:57:10 PM UTC-4, Bruce Wade wrote:
>>
>> Why would you do the code like that??
>>
>> Updated:
>> 
>> jQuery(function() {
>>   var param1 = 'hello'
>>   var param2 = 'world'
>>   jQuery('a#mylink').attr('href'**, '{{=URL("action", args=["' + param1
>> + '","' + param2 + '"])}}');
>> });
>> 
>>
>> {{=A('...', _href='', _id='mylink')}}
>>
>>
>> On Sun, May 20, 2012 at 4:36 PM, Anthony  wrote:
>>
>>>
>>>
>>> On Sunday, May 20, 2012 3:43:38 PM UTC-4, Ashraf Mansour wrote:

 thanks for the immediate reply.

 param1 and param2 are determined on the client side.

 how can it be generated by javascript?


>>> It depends. Here's one example:
>>>
>>> 
>>> jQuery(function() {
>>>   var param1 = 'hello'
>>>   var param2 = 'world'
>>>   jQuery('a#mylink').attr('href'**, '{{=URL("action")}}' + '/' + param1
>>> + '/' + param2);
>>> });
>>> 
>>>
>>> {{=A('...', _href='', _id='mylink')}}
>>>
>>> When the page is loaded, the href of the mylink anchor tag will be
>>> replaced with the "action" URL along with the values of param1 and param2
>>> appended. Of course, you'll need some way to set the values of param1 and
>>> param2, and there may be some other event that should trigger the
>>> replacement -- it depends what you're trying to do.
>>>
>>> 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
>>
>>


-- 
-- 
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: Pass multiple arguments to URL through javascript

2012-05-20 Thread Ashraf Mansour
thank you for your interest.

let me brief what i am doing. I am building an application accessing google 
maps api v3. I need the function that decide if a certain point is within 
certain bounds. my understanding is that i need to do that in the view ( by 
passing the point and the coordinates of the bounds ). the view js can 
access them if they in {{ }}. then I need to return the output of the 
function to the next action, by clicking 

  

it did not work (it does not write the values of param1 and param2 )

and 

   

is not working ( param1, param2 is not defind within {{ }}  )


is there a solution without using jquery?



Re: [web2py] Re: Pass multiple arguments to URL through javascript

2012-05-20 Thread Bruce Wade
You do realise that you are missing the closing >?



Also what you are trying to do in this code will never work.



becomes

/param1/param2 

Try this:



On Sun, May 20, 2012 at 7:09 PM, Ashraf Mansour wrote:

> thank you for your interest.
>
> let me brief what i am doing. I am building an application accessing
> google maps api v3. I need the function that decide if a certain point is
> within certain bounds. my understanding is that i need to do that in the
> view ( by passing the point and the coordinates of the bounds ). the view
> js can access them if they in {{ }}. then I need to return the output of
> the function to the next action, by clicking
>
> 
>
> it did not work (it does not write the values of param1 and param2 )
>
> and
>
> 
>
> is not working ( param1, param2 is not defind within {{ }}  )
>
>
> is there a solution without using jquery?
>
>


-- 
-- 
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: Pass multiple arguments to URL through javascript

2012-05-20 Thread Anthony
I wasn't suggesting he should use the URL() function, just pointing out 
that it *can't* be used to build a URL on the client side, and showing a 
simple example of how to build a URL on the client side via Javascript (use 
of the URL() function was incidental and not central to the point of the 
example). In any given case, it may or may not make sense to use the URL() 
function to build the base URL (vs. hard-coding it in a .js file), and I 
wouldn't state a blanket rule either way (if you're using the web2py 
rewrite system, it's generally a good idea to use URL() whenever feasible).

Also, I hadn't realized you made an update to my code example. The update 
wouldn't work because it attempts to put Javascript variables inside Python 
code that must be executed on the server.

Anthony

On Sunday, May 20, 2012 8:56:51 PM UTC-4, Bruce Wade wrote:
>
> Well honestly if it was a dynamic link I wouldn't even use URL as good 
> style of JS programming is putting the code in a .js if this is the case 
> then the web2py parser cannot even access the URL to parse it. (At least I 
> have never been successful with that process.)
>
> If they are getting the params at a later time and in a js file there is 
> no need in using the URL just use url = '/path/' + param + '/' + param; The 
> only problem with this is if he changes the path, however if he changes the 
> path he would be required to update URL() anyways.
>
> I have fell into the trap on trying to rely on the helpers to much myself 
> in the past. Some places in your code you shouldn't use them. Trying to use 
> them for everything kind of forces you to change your logic to bend around 
> web2py instead of having web2py work with your logic. Also whenever you use 
> URL instead of the direct url='/path' the framework is forced to do more 
> function calls, in some situations like this one it isn't really worth 
> having the extra function call and it is actually more typing :D
>
> On Sun, May 20, 2012 at 5:19 PM, Anthony  wrote:
>
>> He said param1 and param2 are determined on the client side -- which 
>> means they cannot be set on the server side by web2py. Of course, I don't 
>> know what he's actually doing on the client side, so this exact code may or 
>> may not be relevant. Do you have an alternative suggestion?
>>
>> Anthony
>>
>> On Sunday, May 20, 2012 7:57:10 PM UTC-4, Bruce Wade wrote:
>>>
>>> Why would you do the code like that?? 
>>>
>>> Updated: 
>>> 
>>> jQuery(function() {
>>>   var param1 = 'hello'
>>>   var param2 = 'world'
>>>   jQuery('a#mylink').attr('href'**, '{{=URL("action", args=["' + param1 
>>> + '","' + param2 + '"])}}');
>>> });
>>> 
>>>
>>> {{=A('...', _href='', _id='mylink')}}
>>>
>>>
>>> On Sun, May 20, 2012 at 4:36 PM, Anthony  wrote:
>>>


 On Sunday, May 20, 2012 3:43:38 PM UTC-4, Ashraf Mansour wrote:
>
> thanks for the immediate reply.
>
> param1 and param2 are determined on the client side.
>
> how can it be generated by javascript?
>
>
 It depends. Here's one example:

 
 jQuery(function() {
   var param1 = 'hello'
   var param2 = 'world'
   jQuery('a#mylink').attr('href'**, '{{=URL("action")}}' + '/' +param1 
 + '/' + param2);
 });
 

 {{=A('...', _href='', _id='mylink')}}

 When the page is loaded, the href of the mylink anchor tag will be 
 replaced with the "action" URL along with the values of param1 and param2 
 appended. Of course, you'll need some way to set the values of param1 and 
 param2, and there may be some other event that should trigger the 
 replacement -- it depends what you're trying to do.

 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
>>>
>>>
>
>
> -- 
> -- 
> 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: Pass multiple arguments to URL through javascript

2012-05-20 Thread Ashraf Mansour
both

 

and

 


are not working ( they are not showing the values of param1 and param2 )


>

Re: [web2py] Re: Pass multiple arguments to URL through javascript

2012-05-20 Thread Anthony

>
> let me brief what i am doing. I am building an application accessing 
> google maps api v3. I need the function that decide if a certain point is 
> within certain bounds. my understanding is that i need to do that in the 
> view ( by passing the point and the coordinates of the bounds ). the view 
> js can access them if they in {{ }}. 
>

What do you mean by needing to do that "in the view"? Do you mean in the 
browser? If so, that's not the same thing as "in the view". In web2py, the 
view is a special template that can include Python code. The view is 
executed on the server, and the output of that execution is what is sent to 
the browser. The browser does not see any of the Python code (i.e., none of 
the {{...}} end up in the browser).

is there a solution without using jquery?
>

It's still not clear what you are doing. What are param1 and param2? Are 
they determined dynamically within the browser? If so, you'll need 
Javascript to build the URL in the browser (it doesn't have to be jQuery 
specifically, but some form of Javascript). If param1 and param2 are known 
on the server at the time the page is being constructed by web2py, then you 
can simply include them as args in the call to the URL() function.

Anthony 


Re: [web2py] Re: Pass multiple arguments to URL through javascript

2012-05-20 Thread Anthony

>
> both
>
>  
>
> and
>
>  
>
>
> are not working ( they are not showing the values of param1 and param2 )
>

You are simply putting the literal strings "param1" and "param2" directly 
into your HTML there, so of course the values of those variables won't be 
shown. What are param1 and param2? Are they Javascript variables? If so, 
where are they defined? If they are Javascript variables, then you have to 
use Javascript to build the URL -- you cannot just paste Javascript 
variables directly into HTML and have the browser translate them into their 
values.

Anthony


Re: [web2py] Re: Pass multiple arguments to URL through javascript

2012-05-20 Thread Bruce Wade
If param1 and param2 are from javascript:

1) You can not write the code in headers as you have current written you
will have to use something like the following:


// javascript function:
function generateURL(param1, param2) {
   url = '/action/' + param1 + "/" + param2;
   $("url_with_params").attr('href', url);
}

On Sun, May 20, 2012 at 7:41 PM, Ashraf Mansour wrote:

> both
>
> 
>
> and
>
> 
>
>
> are not working ( they are not showing the values of param1 and param2 )
>
>
>>


-- 
-- 
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] ExecuteSQL, nested selects

2012-05-20 Thread Simon Ashley
trying the following expression but get an update according to the first 
record rather than being conditional on specific records processed:

db.executesql("UPDATE Plant SET SiteID=(SELECT Site.id FROM Plant, Site 
WHERE Site.SiteId = Plant.SiteIdLink);") 


 ie. all SiteID's get the value of the first Site.SiteId = Plant.SiteIdLink 
encountered.

Just can't see the solution at present.


[web2py] Routing stuff in apache instead of web2py

2012-05-20 Thread Jason Brower
A suppose it would be a little off topic, but I need it for my web2py 
application.

The book tells me I shouldn't use routes in web2py and use apache.
I have mod_proxy install, as I used the setup-web2py-ubuntu.sh script 
and it seems to have works perfects.
I have the program installed and running at 
http://example.com/interestid/.  When you go there it works perfectly.

But I would like a little more quality and put it here...
http://example.com
An hints on how to get that to work; or better a play-by-play. (I can 
program all day, but apache freaks me right out!)

---
Best Regards,
Jason Brower


[web2py] Re: Web2py and exchange server

2012-05-20 Thread Gergely Orosz
 Hi Khalil,

I have tried telnet to the server and I was able to login fine
Also sent an mail I am going to configure mutt on the server and will try 
it from it as well

Regards
Gergely

On Friday, 18 May 2012 17:45:55 UTC+2, Niphlod wrote:
>
> It's probably not an issue of web2py. 
>
> can you send regular emails from your centos server through exchange with 
> something like sendmail or mutt ? 
>
>

[web2py] Re: Web2py and exchange server

2012-05-20 Thread Gergely Orosz
Hi Niphlod,

I was able to telnet to the exchange server from CentOS
Also sent mail from SMTP over telnet I am going to configure mutt and will 
try send mails from it as well

Regards
Gergely

On Friday, 18 May 2012 17:45:55 UTC+2, Niphlod wrote:
>
> It's probably not an issue of web2py. 
>
> can you send regular emails from your centos server through exchange with 
> something like sendmail or mutt ? 
>
>

[web2py] Re: Routing stuff in apache instead of web2py

2012-05-20 Thread pbreit
I believe if you set the default application in routes.py you will get waht 
you want. From:
http://code.google.com/p/web2py/source/browse/router.example.py

routers = dict(

# base router
BASE = dict(
default_application = 'interestid',
),
)


[web2py] How to prevent delete of a row with SQLFORM.grid -

2012-05-20 Thread François Delpierre
I must ensure there is always at least one row in a table. (My application 
parameter table)
How can I prohibit delete of the last row of a table ?
As it looks the ondelete is executed AFTER deletion...

Thanks,


[web2py] Re: ExecuteSQL, nested selects

2012-05-20 Thread Simon Ashley
To answer my own post, syntax should have been:  

db.executesql("UPDATE Plant SET SiteID=(SELECT Site.id FROM Site WHERE 
Site.SiteId = Plant.SiteIdLink);")  


Sorry about that ... 

On Monday, May 21, 2012 2:50:33 PM UTC+10, Simon Ashley wrote:
>
> trying the following expression but get an update according to the first 
> record rather than being conditional on specific records processed:
>
> db.executesql("UPDATE Plant SET SiteID=(SELECT Site.id FROM Plant, Site 
> WHERE Site.SiteId = Plant.SiteIdLink);") 
>
>
>  ie. all SiteID's get the value of the first Site.SiteId = 
> Plant.SiteIdLink encountered.
>
> Just can't see the solution at present.
>


[web2py] Re: Little problem with scheduler_task - has no signature Fields

2012-05-20 Thread szimszon
Here it is: http://code.google.com/p/osmand/issues/detail?id=1012

Thank you!

2012. május 20., vasárnap 23:19:33 UTC+2 időpontban Massimo Di Pierro a 
következőt írta:
>
> Please open a ticket about this. We can add options to add fields to 
> scheduler tables.
>
> On Friday, 18 May 2012 03:43:38 UTC-5, szimszon wrote:
>>
>> Hi!
>>
>> I wonder if somebody could help me.
>>
>> I have to audit scheduler_task 
>> db.scheduler_task._enable_record_versioning() works but scheduler_task have 
>> no Created On, By and Modified On, By (is_active) Fields :(
>>
>> Can we put this Fields in it?
>>
>