[web2py] Re: trying to add a second button to a form but before the submit button

2013-07-15 Thread Annet
Maybe this will work:

form.element('input[type=submit]', replace=lambda button: 
CAT(INPUT(_class="btn",_type="reset",_value="Reset", button)))

Which adds a reset button, which is not a back button ...

INPUT(_class="btn",_type="button",_value="Back",_onclick="javascript:history.go(-1);")


Regards,

Annet

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Am I outgrowing DAL?

2013-07-15 Thread Niphlod
that psycopg error is a postgresql error. I find very strange that a query 
run through psycopg gives you an error while the "other tool" doesn't. 
However, as stated earlier, in a query with a group by you "must" (read, 
should, even if some tool outsmarts the relationships) fetch either 
aggregates or the columns in the group by clause. That's T-SQL.

Il giorno martedì 16 luglio 2013 06:21:03 UTC+2, Joe Barnhart ha scritto:
>
> Hi Massimo --
>
> Maybe it's the psycopg2 adapter, but it's throwing the error in the 
> message above because there's no aggregate function on A.col1.  It forces 
> me to put the column into the "group by" clause.  I'm thinking maybe my 
> tables aren't as clean as I thought and maybe postgres is telling me that 
> Table A and Table B are not 1:1 as I thought.
>
> Every day is an education!
>
> -- Joe
>
> On Monday, July 15, 2013 5:05:33 PM UTC-7, Massimo Di Pierro wrote:
>>
>> This query 
>>
>> SELECT A.col1, B.col1, count(C.col1)
>> FROM A, B, C
>> WHERE A.b_id=B.id AND C.b_id=B.id
>> GROUP BY B.id
>>
>> in DAL-ese is
>>
>> A, B, C = db.A, db.B, db.C
>> rows = 
>> db((A.b_id==B.id)&(C.b_id==B.id)).select(A.col1,B.col1,C.col1.count(),groupby=B.id)
>>
>> If it works with executesql than it works with DAL-ese.
>>
>>
>>
>> On Monday, 15 July 2013 17:24:51 UTC-5, Joe Barnhart wrote:
>>>
>>> I find I want to do SQL queries that I can't figure out the DAL commands 
>>> for.  For example, using a Postgres database I want to do a three table 
>>> join where:
>>>
>>> Table A  <--1:1-->  Table B <--1:N --> Table C
>>>
>>> I'm using a "group by" on the Table B/C join and aggregating the Table C 
>>> columns for my final table.  My problem is that, even though Table A/B is 
>>> 1:1, the DAL is insisting on aggregation functions on it as well, or 
>>> demanding I put its columns in the "group by" which for some reason makes 
>>> the query die (i.e. take too long to be useful).  
>>>
>>> I know from entering the sql directly into Postgres that it figures out 
>>> the Table A columns don't need any aggregation, but web2py is more 
>>> restrictive.  (Possibly because other databases aren't as forgiving as 
>>> postgres.)  Since it is a query and returns rows, I can't use executesql() 
>>> on it.  I can do it as two queries and "join" in memory but that seems like 
>>> a hassle when SQL was designed to handle this very situation.
>>>
>>> The query I want is something like this:
>>>
>>> SELECT A.col1, B.col1, count(C.col1)
>>> FROM A, B, C
>>> WHERE A.b_id=B.id AND C.b_id=B.id
>>> GROUP BY B.id
>>>
>>> When i try the equivalent in DAL I always get the error that I need to 
>>> put A.col1 in the "group by" clause, but that kills the query on the 
>>> psycopg side.  Plus, the query actually has many more columns than this but 
>>> the underlying structure is the same.
>>>
>>> Do I need to resort to two queries (Table A/B and Table B/C) and do the 
>>> final table joining from Python?  Or is there some DAL-fu I'm missing?
>>>
>>> -- Joe B.
>>>
>>>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] SQLFORM grid returns a error : query object has no attribute _tablename

2013-07-15 Thread Sarbjit singh
I am doing the following steps :

>>> db = DAL('sqlite://storage.db')
>>> db.define_table('person', Field('name'), Field('country'))
>>> db.person.insert(name='John', country='UK')
>>> db.person.insert(name='David', country='US')
>>> query = db.person.name=="David"

>>> SQLFORM.smartgrid(query)

Traceback (most recent call last):
  File "", line 1, in 
  File "\gluon\sqlhtml.py", line 2459, in
smartgrid
if request.args(len(args)) != table._tablename:
AttributeError: 'Query' object has no attribute '_tablename'

While if I try the below code, it works fine.

>>> db(query).select()

Can some one please point me why this query is not working with 
"smartgrid". 

Thanks
Sarbjit


-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: AD Authentication issues

2013-07-15 Thread Koen Vanhees
Thanks Derek!
I found out the issue was caused by a mistake in the admin account 
creation...
*facepalm*
:)

Op maandag 15 juli 2013 19:23:32 UTC+2 schreef Derek het volgende:
>
> Hello Koen! I have some vbscripts if the configuration is the issue.
> First, this lists all your domain controllers. Helpful if you don't know 
> which server is setup to service your ldap requests. You can try all of 
> them.
> Just save this as a 'get server names.vbs' and run it... You just have to 
> be logged in to active directory, and no configuration is needed for these 
> scripts. It will find the configuration of your servers itself.
>
> ---
>
> ldapFilter = "(&(objectClass=nTDSDSA)(options:1.2.840.113556.1.4.803:=1))"
>
> Set rootDSE = GetObject("LDAP://rootDSE")
> configDN =   rootDSE.Get("configurationNamingContext")
>
> Set ado = CreateObject("ADODB.Connection")
> ado.Provider = "ADSDSOObject"
> ado.Open "ADSearch" 
> Set objectList =   ado.Execute(";" & ldapFilter & 
> ";distinguishedName;subtree")
> c = ""
> While Not objectList.EOF
> nTSDSA = objectList.Fields("distinguishedName")
> serverDN = Mid(nTSDSA, 18) 
> 'CN=NTDS Settings abschneiden => Server Objekt
> Set serverObj = GetObject("LDAP://" & serverDN )
> 
> 'WScript.Echo serverObj.dNSHostName
> c = c + serverObj.dNSHostName + " "
>
> objectList.MoveNext
> Wend
> WScript.Echo c
>
> ---
>
> The second script shows your FQDN...
>
> ---
> ' Constants for the NameTranslate object.
> Const ADS_NAME_INITTYPE_GC = 3
> Const ADS_NAME_TYPE_NT4 = 3
> Const ADS_NAME_TYPE_1779 = 1
>
> ' Specify the NetBIOS name of the domain and the NT name of the user.
> strNTName = InputBox("Enter your LOGIN ID:", "Check Login", "domain\login")
>
> ' Use the NameTranslate object to convert the NT user name to the
> ' Distinguished Name required for the LDAP provider.
> Set objTrans = CreateObject("NameTranslate")
>
> ' Initialize NameTranslate by locating the Global Catalog.
> objTrans.Init ADS_NAME_INITTYPE_GC, ""
> ' Use the Set method to specify the NT format of the object name.
> objTrans.Set ADS_NAME_TYPE_NT4, strNTName
>
> ' Use the Get method to retrieve the RFC 1779 Distinguished Name.
> strUserDN = objTrans.Get(ADS_NAME_TYPE_1779)
>
> ' Escape any "/" characters with backslash escape character.
> ' All other characters that need to be escaped will be escaped.
> strUserDN = Replace(strUserDN, "/", "\/")
> wscript.echo "Your user string is: " & strUserDN
>
> ' Bind to the user object in Active Directory with the LDAP provider.
> Set objUser = GetObject("LDAP://" & strUserDN)
> ---
>
> (change the  words "domain\login" and put in your own domain and login, or 
> leave it as is and type in the correct values when prompted) It will also 
> bind to ldap, to test that it works. 
>
> Now to configure LDAP... you need to add this information that you got 
> here (in your models)...
> ---
> from gluon.contrib.login_methods.ldap_auth import ldap_auth
> auth.settings.login_methods = [ldap_auth(mode='ad',
>server='SERVERNAME.FROM.FIRST.SCRIPT',
>base_dn='OU=EMPLOYEES,DC=USA,DC=DIVISION,DC=CORPORATE,DC=com')]
> ---
> That is the configuration line specific to your active directory. For the 
> rest, just follow the AD guide on web2pyslices.
>
> On Monday, July 15, 2013 4:40:59 AM UTC-7, Koen Vanhees wrote:
>>
>> All,
>>
>> I'm having some issues with integrating Active Directory authentication 
>> in my app.
>> Although telnet to the domain controller works, also tcpdump seems to 
>> send and receive information to the domain controller, Logging level set 
>> to"debug" doesn't reveal much more:
>> DEBUG:web2py.auth.ldap_auth:mode: [ad] manage_user: [False] custom_scope: 
>> [subtree] manage_groups: [False]
>> INFO:web2py.auth.ldap_auth:[192.168.1.115] Initialize ldap connection
>>
>> Any hints are very welcome...
>>
>> Cheers,
>> Koen
>>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] FPDF database image

2013-07-15 Thread Tribo Eila
Mariano,

I already took your advised. But I can't figure out this error: 

RuntimeError: FPDF error: PIL not installed

After I installed the latest Binary Installer of PIL to python/../site-package. 
Still error exist.
Copy the folder to web2py/../site-packages, still the same.

I tried to import PIL in python command line. No error.

Any advised?

Regards,

Eila


On Monday, July 15, 2013 6:49:00 PM UTC+3, Mariano Reingart wrote:
>
> You shoud have the picture in a file, so PyFPDF can load it. 
>
> Take a look at  build_badge_dict in web2conf: 
>
> https://code.google.com/p/web2conf/source/browse/controllers/badge.py#103 
>
> It uses some icons (speaker, country flag) from the private directory, 
> and uses the sponsor logo from a upload field in the database. 
>
> Basically, you should pass the full image path to PyFPDF (sponsor.logo 
> is the upload field): 
>
> fn = db.sponsor[user.sponsor_id].logo 
> source = os.path.join(request.folder, 'uploads', fn) 
>
> See the sample function, that uses that info to generate the pdf. 
>
> Best regads 
>
> Mariano Reingart 
> http://www.sistemasagiles.com.ar 
> http://reingart.blogspot.com 
>
>
> On Mon, Jul 15, 2013 at 2:03 AM, Tribo Eila 
> > 
> wrote: 
> > Hi, 
> > 
> > Supposed the code below: 
> > 
> > db.define_table('person', 
> > Field('name'), 
> > Field('picture', 'upload')). 
> > 
> > I'm trying to figured out, how to implement the picture to retrieve from 
> > database(postgreSQL) to FPDF. 
> > 
> > Any ideas to share? 
> > 
> > Thanks. 
> > 
> > Newbie 
> > 
> > 
> > 
> > 
> > -- 
> > 
> > --- 
> > You received this message because you are subscribed to the Google 
> Groups 
> > "web2py-users" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> an 
> > email to web2py+un...@googlegroups.com . 
> > For more options, visit https://groups.google.com/groups/opt_out. 
> > 
> > 
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] dynamic search form

2013-07-15 Thread Sarbjit singh


On Monday, April 26, 2010 7:17:55 AM UTC+5:30, mr.freeze wrote:
>
> Just thought I would share a small slice I made recently. It's creates 
> a search form for a table with selectable fields and criteria. 
> http://www.web2pyslices.com/main/slices/take_slice/78 
>
>
> -- 
> Subscription settings: 
> http://groups.google.com/group/web2py/subscribe?hl=en 
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: dynamic search form

2013-07-15 Thread Sarbjit singh
Hi, 

I have been trying to use the dynamic search with SMARTGRID. But it is not 
working. I modified the code as :

 results = db(query).select(*selected) 

 ==MODIFIED TO ==>

 results = SQLFORM.smartgrid(query) 

With this modification, it is giving the below error :-

"Query" object has no attribute "_tablename"

Can you please help me to resolve this error.

-Sarbjit

On Monday, April 26, 2010 8:45:45 AM UTC+5:30, mdipierro wrote:
>
> I think we should include this in crud. Would you send me a patch? 
>
> On Apr 25, 8:47 pm, "mr.freeze"  wrote: 
> > Just thought I would share a small slice I made recently. It's creates 
> > a search form for a table with selectable fields and criteria.
> http://www.web2pyslices.com/main/slices/take_slice/78 
> > 
> > -- 
> > Subscription settings:
> http://groups.google.com/group/web2py/subscribe?hl=en 
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] trying to add a second button to a form but before the submit button

2013-07-15 Thread Jim Gregory
Oops, that I think will put the reset button too many elements ahead. To add a 
reset button as the last form element, try:

form[0].append(TAG.button('Reset', _type = 'reset', ...)

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Am I outgrowing DAL?

2013-07-15 Thread Joe Barnhart
Hi Massimo --

Maybe it's the psycopg2 adapter, but it's throwing the error in the message 
above because there's no aggregate function on A.col1.  It forces me to put 
the column into the "group by" clause.  I'm thinking maybe my tables aren't 
as clean as I thought and maybe postgres is telling me that Table A and 
Table B are not 1:1 as I thought.

Every day is an education!

-- Joe

On Monday, July 15, 2013 5:05:33 PM UTC-7, Massimo Di Pierro wrote:
>
> This query 
>
> SELECT A.col1, B.col1, count(C.col1)
> FROM A, B, C
> WHERE A.b_id=B.id AND C.b_id=B.id
> GROUP BY B.id
>
> in DAL-ese is
>
> A, B, C = db.A, db.B, db.C
> rows = 
> db((A.b_id==B.id)&(C.b_id==B.id)).select(A.col1,B.col1,C.col1.count(),groupby=B.id)
>
> If it works with executesql than it works with DAL-ese.
>
>
>
> On Monday, 15 July 2013 17:24:51 UTC-5, Joe Barnhart wrote:
>>
>> I find I want to do SQL queries that I can't figure out the DAL commands 
>> for.  For example, using a Postgres database I want to do a three table 
>> join where:
>>
>> Table A  <--1:1-->  Table B <--1:N --> Table C
>>
>> I'm using a "group by" on the Table B/C join and aggregating the Table C 
>> columns for my final table.  My problem is that, even though Table A/B is 
>> 1:1, the DAL is insisting on aggregation functions on it as well, or 
>> demanding I put its columns in the "group by" which for some reason makes 
>> the query die (i.e. take too long to be useful).  
>>
>> I know from entering the sql directly into Postgres that it figures out 
>> the Table A columns don't need any aggregation, but web2py is more 
>> restrictive.  (Possibly because other databases aren't as forgiving as 
>> postgres.)  Since it is a query and returns rows, I can't use executesql() 
>> on it.  I can do it as two queries and "join" in memory but that seems like 
>> a hassle when SQL was designed to handle this very situation.
>>
>> The query I want is something like this:
>>
>> SELECT A.col1, B.col1, count(C.col1)
>> FROM A, B, C
>> WHERE A.b_id=B.id AND C.b_id=B.id
>> GROUP BY B.id
>>
>> When i try the equivalent in DAL I always get the error that I need to 
>> put A.col1 in the "group by" clause, but that kills the query on the 
>> psycopg side.  Plus, the query actually has many more columns than this but 
>> the underlying structure is the same.
>>
>> Do I need to resort to two queries (Table A/B and Table B/C) and do the 
>> final table joining from Python?  Or is there some DAL-fu I'm missing?
>>
>> -- Joe B.
>>
>>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] trying to add a second button to a form but before the submit button

2013-07-15 Thread Jim Gregory
Will this work?

form[0].insert(-2,TAG.button('Reset', _type='reset', ...) 

- Jim

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] how to validate forms using extra data?

2013-07-15 Thread Jim Gregory
Your workaround idea worked great. Thanks.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] trying to add a second button to a form but before the submit button

2013-07-15 Thread Tim Richardson
I want to add a back button before the submit button on a SQLFORM.
I don't understand how to use the button attribute, but from searching this 
should work (adding a button after the form is created)

but I don't see anything other than the submit button :(




def form_test(): #controller function
form = SQLFORM(db.person)
form.element(_type='submit').parent =  [
  TAG.button('Submit', _id="px-submit",_type="submit"),
  TAG.button('Reset',_id="px-clear",_type="reset"),
]
if form.process().accepted:
   response.flash = 'form accepted, thanks!'
elif form.errors:
   response.flash = 'form has errors'
return dict(form=form)

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Dynamic fields in dal

2013-07-15 Thread Juan BC
actually im working on kdd/dataminning science proyect, and i try to port 
the connection code from Peewee-orm to dal.

the requirements of my project are this:

1 - i need to create a db without a .tables file2 - some variables fields are 
added dynamically and stored in a diferent table3 - My example table is: foo4 - 
My table for dynamic fields is: dynamic_field5 - you can "load" an existing 
databases and reload all the dynamic fields


The minimun example is here: http://dpaste.com/hold/1303925/

and the "real" code is here: 
https://bitbucket.org/leliel12/yatel/src/tip/yatel/db2.py (the _init method 
is where the load lives)

The question is simple... because this not work: what can i do to make this 
code work?

thanks in advance







-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Am I outgrowing DAL?

2013-07-15 Thread Massimo Di Pierro
This query 

SELECT A.col1, B.col1, count(C.col1)
FROM A, B, C
WHERE A.b_id=B.id AND C.b_id=B.id
GROUP BY B.id

in DAL-ese is

A, B, C = db.A, db.B, db.C
rows = 
db((A.b_id==B.id)&(C.b_id==B.id)).select(A.col1,B.col1,C.col1.count(),groupby=B.id)

If it works with executesql than it works with DAL-ese.



On Monday, 15 July 2013 17:24:51 UTC-5, Joe Barnhart wrote:
>
> I find I want to do SQL queries that I can't figure out the DAL commands 
> for.  For example, using a Postgres database I want to do a three table 
> join where:
>
> Table A  <--1:1-->  Table B <--1:N --> Table C
>
> I'm using a "group by" on the Table B/C join and aggregating the Table C 
> columns for my final table.  My problem is that, even though Table A/B is 
> 1:1, the DAL is insisting on aggregation functions on it as well, or 
> demanding I put its columns in the "group by" which for some reason makes 
> the query die (i.e. take too long to be useful).  
>
> I know from entering the sql directly into Postgres that it figures out 
> the Table A columns don't need any aggregation, but web2py is more 
> restrictive.  (Possibly because other databases aren't as forgiving as 
> postgres.)  Since it is a query and returns rows, I can't use executesql() 
> on it.  I can do it as two queries and "join" in memory but that seems like 
> a hassle when SQL was designed to handle this very situation.
>
> The query I want is something like this:
>
> SELECT A.col1, B.col1, count(C.col1)
> FROM A, B, C
> WHERE A.b_id=B.id AND C.b_id=B.id
> GROUP BY B.id
>
> When i try the equivalent in DAL I always get the error that I need to put 
> A.col1 in the "group by" clause, but that kills the query on the psycopg 
> side.  Plus, the query actually has many more columns than this but the 
> underlying structure is the same.
>
> Do I need to resort to two queries (Table A/B and Table B/C) and do the 
> final table joining from Python?  Or is there some DAL-fu I'm missing?
>
> -- Joe B.
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Am I outgrowing DAL?

2013-07-15 Thread Joe Barnhart
Here it is:

 column "meet_stage.name" must appear in 
the GROUP BY clause or be used in an aggregate function LINE 1: 
...es_stage.name), COUNT(DISTINCT times_stage.club), meet_stage... ^

I guess this is a psycopg2 error.  Which is kinda weird because when I take 
the SQL and feed it directly into the Postgres sql tool it figures out that 
"meet_stage.name" has a 1:1 relationship and runs fine.

I found that putting all the columns in the "group by" was not as toxic as 
it first seemed and it is working OK for me now.  The query is still very 
slow, but this is a seldom-used housekeeping part of the site and speed is 
not as important...

Joe

On Monday, July 15, 2013 4:09:23 PM UTC-7, Niphlod wrote:
>
> I don't remember any DAL code that prevents something like that. From a 
> theoretical standpoint though, every column that is not aggregated in the 
> returned resultset in a group by clause must be included in the groupby 
> itself.
> Can you post the DAL error ?
>
> On Tuesday, July 16, 2013 12:24:51 AM UTC+2, Joe Barnhart wrote:
>>
>> I find I want to do SQL queries that I can't figure out the DAL commands 
>> for.  For example, using a Postgres database I want to do a three table 
>> join where:
>>
>> Table A  <--1:1-->  Table B <--1:N --> Table C
>>
>> I'm using a "group by" on the Table B/C join and aggregating the Table C 
>> columns for my final table.  My problem is that, even though Table A/B is 
>> 1:1, the DAL is insisting on aggregation functions on it as well, or 
>> demanding I put its columns in the "group by" which for some reason makes 
>> the query die (i.e. take too long to be useful).  
>>
>> I know from entering the sql directly into Postgres that it figures out 
>> the Table A columns don't need any aggregation, but web2py is more 
>> restrictive.  (Possibly because other databases aren't as forgiving as 
>> postgres.)  Since it is a query and returns rows, I can't use executesql() 
>> on it.  I can do it as two queries and "join" in memory but that seems like 
>> a hassle when SQL was designed to handle this very situation.
>>
>> The query I want is something like this:
>>
>> SELECT A.col1, B.col1, count(C.col1)
>> FROM A, B, C
>> WHERE A.b_id=B.id AND C.b_id=B.id
>> GROUP BY B.id
>>
>> When i try the equivalent in DAL I always get the error that I need to 
>> put A.col1 in the "group by" clause, but that kills the query on the 
>> psycopg side.  Plus, the query actually has many more columns than this but 
>> the underlying structure is the same.
>>
>> Do I need to resort to two queries (Table A/B and Table B/C) and do the 
>> final table joining from Python?  Or is there some DAL-fu I'm missing?
>>
>> -- Joe B.
>>
>>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: File not stored in "uploadfolder"

2013-07-15 Thread Niphlod
no 'blob' fields involved ?
first thing is NEVER use string concatenation to figure out a path. use 
os.path.join() .
second thing is, use request.folder as the root folder for everything, or 
you loose the ability to have your application contained in a single 
folder. request.application is just the application name.
third thing is that if it's available on appadmin and no 'blob' field is 
involved, it MUST be somewhere in your pc. 

On Monday, July 15, 2013 6:51:28 PM UTC+2, lesssugar wrote:
>
> I have the following upload field definition:
>
> ...
> Field('application', 'upload', uploadfolder=request.application + 
> '/uploads/applications', autodelete=True)
> ...
>
> db.mytable.application.requires = IS_UPLOAD_FILENAME(extension=
> '(doc|DOC|docx|DOCX|pdf|PDF|odt|ODT|rtf|RTF)', error_message='Use PDF, 
> DOC, DOCX, ODT or RTF')
>
> The upload is being performed with no errors and the file is available for 
> download via Appadmin. However, the file itself is not stored in the 
> specified upload folder, which remains empty. Neither is the file stored in 
> app/uploads.
>
> What am I doing wrong and where is my uploaded file being saved?
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Am I outgrowing DAL?

2013-07-15 Thread Niphlod
I don't remember any DAL code that prevents something like that. From a 
theoretical standpoint though, every column that is not aggregated in the 
returned resultset in a group by clause must be included in the groupby 
itself.
Can you post the DAL error ?

On Tuesday, July 16, 2013 12:24:51 AM UTC+2, Joe Barnhart wrote:
>
> I find I want to do SQL queries that I can't figure out the DAL commands 
> for.  For example, using a Postgres database I want to do a three table 
> join where:
>
> Table A  <--1:1-->  Table B <--1:N --> Table C
>
> I'm using a "group by" on the Table B/C join and aggregating the Table C 
> columns for my final table.  My problem is that, even though Table A/B is 
> 1:1, the DAL is insisting on aggregation functions on it as well, or 
> demanding I put its columns in the "group by" which for some reason makes 
> the query die (i.e. take too long to be useful).  
>
> I know from entering the sql directly into Postgres that it figures out 
> the Table A columns don't need any aggregation, but web2py is more 
> restrictive.  (Possibly because other databases aren't as forgiving as 
> postgres.)  Since it is a query and returns rows, I can't use executesql() 
> on it.  I can do it as two queries and "join" in memory but that seems like 
> a hassle when SQL was designed to handle this very situation.
>
> The query I want is something like this:
>
> SELECT A.col1, B.col1, count(C.col1)
> FROM A, B, C
> WHERE A.b_id=B.id AND C.b_id=B.id
> GROUP BY B.id
>
> When i try the equivalent in DAL I always get the error that I need to put 
> A.col1 in the "group by" clause, but that kills the query on the psycopg 
> side.  Plus, the query actually has many more columns than this but the 
> underlying structure is the same.
>
> Do I need to resort to two queries (Table A/B and Table B/C) and do the 
> final table joining from Python?  Or is there some DAL-fu I'm missing?
>
> -- Joe B.
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: this talk...

2013-07-15 Thread samuel bonilla
Money and Open Source.https://medium.com/open-source-life/d44a1953749c


El domingo, 14 de julio de 2013 11:03:06 UTC-5, Massimo Di Pierro escribió:
>
> https://vimeo.com/2723800
>
> I think this talk is really relevant to our community, and it gets really 
> funny after the first 19 minute.
>
> Massimo
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Am I outgrowing DAL?

2013-07-15 Thread Joe Barnhart
I find I want to do SQL queries that I can't figure out the DAL commands 
for.  For example, using a Postgres database I want to do a three table 
join where:

Table A  <--1:1-->  Table B <--1:N --> Table C

I'm using a "group by" on the Table B/C join and aggregating the Table C 
columns for my final table.  My problem is that, even though Table A/B is 
1:1, the DAL is insisting on aggregation functions on it as well, or 
demanding I put its columns in the "group by" which for some reason makes 
the query die (i.e. take too long to be useful).  

I know from entering the sql directly into Postgres that it figures out the 
Table A columns don't need any aggregation, but web2py is more restrictive. 
 (Possibly because other databases aren't as forgiving as postgres.)  Since 
it is a query and returns rows, I can't use executesql() on it.  I can do 
it as two queries and "join" in memory but that seems like a hassle when 
SQL was designed to handle this very situation.

The query I want is something like this:

SELECT A.col1, B.col1, count(C.col1)
FROM A, B, C
WHERE A.b_id=B.id AND C.b_id=B.id
GROUP BY B.id

When i try the equivalent in DAL I always get the error that I need to put 
A.col1 in the "group by" clause, but that kills the query on the psycopg 
side.  Plus, the query actually has many more columns than this but the 
underlying structure is the same.

Do I need to resort to two queries (Table A/B and Table B/C) and do the 
final table joining from Python?  Or is there some DAL-fu I'm missing?

-- Joe B.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Lost edit option

2013-07-15 Thread Massimo Di Pierro
there is an option to remove compilation. You should only compile if you 
plan to distribute it and do now want to give away the source code.

On Monday, 15 July 2013 15:33:15 UTC-5, ndave wrote:
>
> Ya i compiled. But what if i want to make more changes?
>
> On Monday, July 15, 2013 12:02:11 PM UTC-7, ndave wrote:
>>
>> I can't view the edit option in the manage list of each application. Why?
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: How to handle multiple domains with the same application

2013-07-15 Thread Massimo Di Pierro
That's even easier In the model:

if request.env.host_name == 'mydomain.com'
uri = 'mydomain.com.sqlite'
css = URL('static','mydomain.com/style.css')
elif:
 # etc etc
 pass 

db =  DAL(uri)
response.files.append(css)

On Monday, 15 July 2013 14:41:49 UTC-5, Derek wrote:
>
> I think he wanted different domains, but the same app. each domain would 
> have it's own stylesheet...
>
> perhaps you could just use the same database. then you setup multitenancy, 
> but that's not quite what you want, since you might have one game on all 
> three sites, one game on only two sites, and one game on one specific site 
> only...
>
> On Monday, July 15, 2013 1:43:37 AM UTC-7, Massimo Di Pierro wrote:
>>
>> Yes. For example I have this in my routes.py file:
>>
>> routes_in=[
>> ('^.*:https?://(www.)?fermiqcd.com:\w+ /','/fermiqcd'),
>> ('^.*:https?://(www.)?experts4solutions.com:\w+ /','/e4s'),
>> ('^.*:https?://evote.experts4solutions.com:\w+ /','/evote'),
>> ('^.*:https?://(www.)?ptolincoln.org:\w+ /','/pto'),
>> ('^.*:https://(.*)election.name:\w+ /','/evote'),
>> ('/','/examples/default/index'),
>> ('/robots.txt','/examples/static/robots.txt'),
>> ('/favicon.ico','/examples/static/favicon.ico')]
>>
>> It tells how to map paths (for each domain) into which web2py application.
>>
>>
>>
>> On Sunday, 14 July 2013 18:22:31 UTC-5, Marcio Andrey Oliveira wrote:
>>>
>>> Hi.
>>>
>>> Currently I have 3 arcade sites: 1 with all kinds of games, 1 with only 
>>> girls games and another one with only escaping games.
>>>
>>> Each site is running in a separated script, and worst than that is that 
>>> I have some games in girls game site and on escaping games sites that exist 
>>> on general arcade site. It means I'm expending database and disk space with 
>>> duplicated date.
>>>
>>> I want to make one application that will receive requests from all 
>>> domains and according to the domain, it will show a different look and feel 
>>> with its respective games.
>>>
>>> How do I do it in web2py? I mean, how do I handle resources based in the 
>>> domain user typed in browser? 
>>>
>>> Regards.
>>>
>>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Lost edit option

2013-07-15 Thread ndave
Ya i compiled. But what if i want to make more changes?

On Monday, July 15, 2013 12:02:11 PM UTC-7, ndave wrote:
>
> I can't view the edit option in the manage list of each application. Why?

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: How to insert line breaks in table cell created by a virtual field

2013-07-15 Thread Woody
Perfect!  That did the trick.

On Monday, July 15, 2013 4:39:05 AM UTC-4, Massimo Di Pierro wrote:
>
> Try this:
>
> db.table.field = Field.Virtual('alert_time', 
> lambda row: XML(str( integer>) + ' hours' + str( datetime>)))
>
> On Sunday, 14 July 2013 17:40:28 UTC-5, Woody wrote:
>>
>> I have a virtual field that concatenates 2 fields like this:
>>
>> Field.Virtual('alert_time', 
>> lambda row: (str(> integer>) + ' hours | ' + str())
>>
>  
>
>>
>> The result goes into a table cell and looks something like this:  "8 
>> hours 2013-07-14 09:10:20"
>>
>> I want to force  line breaks so that it will look like this
>>  8 hours
>>   2013-07-14
>> 09:10:20
>>
>> I tried inserting line breaks using /n or  in the text like this:
>>
>> lambda row: (str() + ' hours/n' 
>> + str())
>>
>> but they printed out as string literals in the table.  How can I format 
>> the text for this cell?
>>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: How to handle multiple domains with the same application

2013-07-15 Thread Derek
I think he wanted different domains, but the same app. each domain would 
have it's own stylesheet...

perhaps you could just use the same database. then you setup multitenancy, 
but that's not quite what you want, since you might have one game on all 
three sites, one game on only two sites, and one game on one specific site 
only...

On Monday, July 15, 2013 1:43:37 AM UTC-7, Massimo Di Pierro wrote:
>
> Yes. For example I have this in my routes.py file:
>
> routes_in=[
> ('^.*:https?://(www.)?fermiqcd.com:\w+ /','/fermiqcd'),
> ('^.*:https?://(www.)?experts4solutions.com:\w+ /','/e4s'),
> ('^.*:https?://evote.experts4solutions.com:\w+ /','/evote'),
> ('^.*:https?://(www.)?ptolincoln.org:\w+ /','/pto'),
> ('^.*:https://(.*)election.name:\w+ /','/evote'),
> ('/','/examples/default/index'),
> ('/robots.txt','/examples/static/robots.txt'),
> ('/favicon.ico','/examples/static/favicon.ico')]
>
> It tells how to map paths (for each domain) into which web2py application.
>
>
>
> On Sunday, 14 July 2013 18:22:31 UTC-5, Marcio Andrey Oliveira wrote:
>>
>> Hi.
>>
>> Currently I have 3 arcade sites: 1 with all kinds of games, 1 with only 
>> girls games and another one with only escaping games.
>>
>> Each site is running in a separated script, and worst than that is that I 
>> have some games in girls game site and on escaping games sites that exist 
>> on general arcade site. It means I'm expending database and disk space with 
>> duplicated date.
>>
>> I want to make one application that will receive requests from all 
>> domains and according to the domain, it will show a different look and feel 
>> with its respective games.
>>
>> How do I do it in web2py? I mean, how do I handle resources based in the 
>> domain user typed in browser? 
>>
>> Regards.
>>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Lost edit option

2013-07-15 Thread Massimo Di Pierro
Perhaps they are compiled?

On Monday, 15 July 2013 14:02:11 UTC-5, ndave wrote:
>
> I can't view the edit option in the manage list of each application. Why?

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Lost edit option

2013-07-15 Thread ndave
I can't view the edit option in the manage list of each application. Why?

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: AD Authentication issues

2013-07-15 Thread Derek
Hello Koen! I have some vbscripts if the configuration is the issue.
First, this lists all your domain controllers. Helpful if you don't know 
which server is setup to service your ldap requests. You can try all of 
them.
Just save this as a 'get server names.vbs' and run it... You just have to 
be logged in to active directory, and no configuration is needed for these 
scripts. It will find the configuration of your servers itself.

---

ldapFilter = "(&(objectClass=nTDSDSA)(options:1.2.840.113556.1.4.803:=1))"

Set rootDSE = GetObject("LDAP://rootDSE")
configDN =   rootDSE.Get("configurationNamingContext")

Set ado = CreateObject("ADODB.Connection")
ado.Provider = "ADSDSOObject"
ado.Open "ADSearch" 
Set objectList =   ado.Execute(";" & ldapFilter & 
";distinguishedName;subtree")
c = ""
While Not objectList.EOF
nTSDSA = objectList.Fields("distinguishedName")
serverDN = Mid(nTSDSA, 18) 
'CN=NTDS Settings abschneiden => Server Objekt
Set serverObj = GetObject("LDAP://" & serverDN )

'WScript.Echo serverObj.dNSHostName
c = c + serverObj.dNSHostName + " "

objectList.MoveNext
Wend
WScript.Echo c

---

The second script shows your FQDN...

---
' Constants for the NameTranslate object.
Const ADS_NAME_INITTYPE_GC = 3
Const ADS_NAME_TYPE_NT4 = 3
Const ADS_NAME_TYPE_1779 = 1

' Specify the NetBIOS name of the domain and the NT name of the user.
strNTName = InputBox("Enter your LOGIN ID:", "Check Login", "domain\login")

' Use the NameTranslate object to convert the NT user name to the
' Distinguished Name required for the LDAP provider.
Set objTrans = CreateObject("NameTranslate")

' Initialize NameTranslate by locating the Global Catalog.
objTrans.Init ADS_NAME_INITTYPE_GC, ""
' Use the Set method to specify the NT format of the object name.
objTrans.Set ADS_NAME_TYPE_NT4, strNTName

' Use the Get method to retrieve the RFC 1779 Distinguished Name.
strUserDN = objTrans.Get(ADS_NAME_TYPE_1779)

' Escape any "/" characters with backslash escape character.
' All other characters that need to be escaped will be escaped.
strUserDN = Replace(strUserDN, "/", "\/")
wscript.echo "Your user string is: " & strUserDN

' Bind to the user object in Active Directory with the LDAP provider.
Set objUser = GetObject("LDAP://" & strUserDN)
---

(change the  words "domain\login" and put in your own domain and login, or 
leave it as is and type in the correct values when prompted) It will also 
bind to ldap, to test that it works. 

Now to configure LDAP... you need to add this information that you got here 
(in your models)...
---
from gluon.contrib.login_methods.ldap_auth import ldap_auth
auth.settings.login_methods = [ldap_auth(mode='ad',
   server='SERVERNAME.FROM.FIRST.SCRIPT',
   base_dn='OU=EMPLOYEES,DC=USA,DC=DIVISION,DC=CORPORATE,DC=com')]
---
That is the configuration line specific to your active directory. For the 
rest, just follow the AD guide on web2pyslices.

On Monday, July 15, 2013 4:40:59 AM UTC-7, Koen Vanhees wrote:
>
> All,
>
> I'm having some issues with integrating Active Directory authentication in 
> my app.
> Although telnet to the domain controller works, also tcpdump seems to send 
> and receive information to the domain controller, Logging level set 
> to"debug" doesn't reveal much more:
> DEBUG:web2py.auth.ldap_auth:mode: [ad] manage_user: [False] custom_scope: 
> [subtree] manage_groups: [False]
> INFO:web2py.auth.ldap_auth:[192.168.1.115] Initialize ldap connection
>
> Any hints are very welcome...
>
> Cheers,
> Koen
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] File not stored in "uploadfolder"

2013-07-15 Thread lesssugar
I have the following upload field definition:

...
Field('application', 'upload', uploadfolder=request.application + 
'/uploads/applications', autodelete=True)
...

db.mytable.application.requires = IS_UPLOAD_FILENAME(extension=
'(doc|DOC|docx|DOCX|pdf|PDF|odt|ODT|rtf|RTF)', error_message='Use PDF, DOC, 
DOCX, ODT or RTF')

The upload is being performed with no errors and the file is available for 
download via Appadmin. However, the file itself is not stored in the 
specified upload folder, which remains empty. Neither is the file stored in 
app/uploads.

What am I doing wrong and where is my uploaded file being saved?

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Rendering image buffer with IMG() helper?

2013-07-15 Thread Lamps902
This works fine for generating an image from a buffer:

import base64

img_buffer = io.BytesIO()
pylab.savefig(img_buffer, format = 'png')
img_buffer.seek(0)

IMG(_src='data:image/png;base64,' + base64.b64encode(img_buffer.getvalue(), 
_alt = 'image buffer not displaying'))

However, as Massimo points out, it's best if I switch to matplotlib. 
Thanks, guys!

On Monday, July 8, 2013 2:59:22 PM UTC-5, Anthony wrote:
>
> No, now you're trying to put the whole image in the URL query string. Just 
> let the URL point to the render_image function, and create the image in 
> that function. You cannot create the image in the same action that produces 
> the URL. First you have to return an HTML page with an image element. Then 
> the browser requests the src of the image element. The image must be 
> fetched in a separate request -- you cannot embed it in the original HTML 
> page that is returned.
>
> Anthony
>
> On Monday, July 8, 2013 3:43:22 PM UTC-4, Lamps902 wrote:
>>
>> Maybe I'm a bit confused on how to generate/stream the image, given the 
>> buffer. The following should work, right?
>>
>> def render_image():
>>return Image.open(request.vars.image_buffer)
>>
>> ...
>> img_buffer = io.BytesIO()
>> pylab.savefig(img_buffer, format = 'png')
>> img_buffer.seek(0)
>>
>> return dict(img = IMG(_src=URL('render_image', vars=dict(image_buffer = 
>> img_buffer)), _alt = 'image buffer not displaying'))
>>
>> Or is there something other than Image.open() that's a better solution?
>>
>> On Monday, July 8, 2013 1:04:38 PM UTC-5, Anthony wrote:
>>>
>>>
>>> On Monday, July 8, 2013 12:49:19 PM UTC-5, Anthony wrote:
>
> The IMG() helper simply creates an HTML  element to be displayed 
> in the browser. The "src" attribute of an image element should be a URL 
> where the browser can request the image. You cannot pass an actual image 
> file object to the helper.


>>> Just make the "src" URL an action that generates the image and streams 
>>> it. 
>>>
>>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: 100% CPU usage when 20GB of pictures in static

2013-07-15 Thread Marian Siwiak
@Richard - I found it. Thank you. I don't know how could I miss it.
@ Massimo - you're right, it was local development server, but top pointed
to web2py as guilty.
When I was installing web2py (1.99 back then), however, I was unable to set
all those VirtualHost issues to have two separately working servers, but
maybe I'll have to.
Best regards,
Marian


On Mon, Jul 15, 2013 at 5:38 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> Are you accessing it from localhost? I suspect it is the browser which is
> using 100% of the CPU, not the server. Anyway, it is more efficient to use
> nginx or apache to serve static files, rather then web2py.
>
>
> On Monday, 15 July 2013 10:25:25 UTC-5, Marian Siwiak wrote:
>>
>> Hello everybody,
>>
>> I have a problem, I have a huge database of png files, which need to be
>> accessed by users of my system, however, when I place them in 'static'
>> folder, web2py used 100 of my CPU (and it's not 286 architecture...).
>> Any advice? I never found a way to create links leading outside
>> application folder, but it would be a solution.
>>
>> Best regards,
>> Marian
>>
>  --
>
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/web2py/s7UtPveDC2I/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] FPDF database image

2013-07-15 Thread Mariano Reingart
You shoud have the picture in a file, so PyFPDF can load it.

Take a look at  build_badge_dict in web2conf:

https://code.google.com/p/web2conf/source/browse/controllers/badge.py#103

It uses some icons (speaker, country flag) from the private directory,
and uses the sponsor logo from a upload field in the database.

Basically, you should pass the full image path to PyFPDF (sponsor.logo
is the upload field):

fn = db.sponsor[user.sponsor_id].logo
source = os.path.join(request.folder, 'uploads', fn)

See the sample function, that uses that info to generate the pdf.

Best regads

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


On Mon, Jul 15, 2013 at 2:03 AM, Tribo Eila  wrote:
> Hi,
>
> Supposed the code below:
>
> db.define_table('person',
> Field('name'),
> Field('picture', 'upload')).
>
> I'm trying to figured out, how to implement the picture to retrieve from
> database(postgreSQL) to FPDF.
>
> Any ideas to share?
>
> Thanks.
>
> Newbie
>
>
>
>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: 100% CPU usage when 20GB of pictures in static

2013-07-15 Thread Massimo Di Pierro
Are you accessing it from localhost? I suspect it is the browser which is 
using 100% of the CPU, not the server. Anyway, it is more efficient to use 
nginx or apache to serve static files, rather then web2py.

On Monday, 15 July 2013 10:25:25 UTC-5, Marian Siwiak wrote:
>
> Hello everybody,
>
> I have a problem, I have a huge database of png files, which need to be 
> accessed by users of my system, however, when I place them in 'static' 
> folder, web2py used 100 of my CPU (and it's not 286 architecture...). 
> Any advice? I never found a way to create links leading outside 
> application folder, but it would be a solution.
>
> Best regards,
> Marian
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] 100% CPU usage when 20GB of pictures in static

2013-07-15 Thread Richard Vézina
Here apache conf :

http://web2py.com/books/default/chapter/29/13

Richard


On Mon, Jul 15, 2013 at 11:36 AM, Richard Vézina <
ml.richard.vez...@gmail.com> wrote:

> I think in deployment recipe in the book there is instruction on how let
> nginx or apache server static file directly without web2py intervention
> have you read it?
>
> I try to found the part I am talking about and paste the link
>
> Richard
>
>
> On Mon, Jul 15, 2013 at 11:25 AM, Marian Siwiak  wrote:
>
>> Hello everybody,
>>
>> I have a problem, I have a huge database of png files, which need to be
>> accessed by users of my system, however, when I place them in 'static'
>> folder, web2py used 100 of my CPU (and it's not 286 architecture...).
>> Any advice? I never found a way to create links leading outside
>> application folder, but it would be a solution.
>>
>> Best regards,
>> Marian
>>
>> --
>>
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "web2py-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to web2py+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] 100% CPU usage when 20GB of pictures in static

2013-07-15 Thread Richard Vézina
I think in deployment recipe in the book there is instruction on how let
nginx or apache server static file directly without web2py intervention
have you read it?

I try to found the part I am talking about and paste the link

Richard


On Mon, Jul 15, 2013 at 11:25 AM, Marian Siwiak  wrote:

> Hello everybody,
>
> I have a problem, I have a huge database of png files, which need to be
> accessed by users of my system, however, when I place them in 'static'
> folder, web2py used 100 of my CPU (and it's not 286 architecture...).
> Any advice? I never found a way to create links leading outside
> application folder, but it would be a solution.
>
> Best regards,
> Marian
>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] 100% CPU usage when 20GB of pictures in static

2013-07-15 Thread Marian Siwiak
Hello everybody,

I have a problem, I have a huge database of png files, which need to be 
accessed by users of my system, however, when I place them in 'static' 
folder, web2py used 100 of my CPU (and it's not 286 architecture...). 
Any advice? I never found a way to create links leading outside application 
folder, but it would be a solution.

Best regards,
Marian

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] do I need a callback ?

2013-07-15 Thread Richard Vézina
Ok, I got it :

def delete_thumb():
row = db(db.auth_user.id == auth.user_id).select().first()
old_folder_name  =
db.auth_user['image'].retrieve_file_properties(row['image'])['path']
old_file_name = row['image']
old_files_names_suffix = ['address_book_thumb', 'profile_thumb']
old_paths = []
for file_name_suffix in old_files_names_suffix:
root, ext = os.path.splitext(old_file_name)
file_name = '%s_%s%s' % (root, file_name_suffix, ext)
old_paths.append(os.path.join(old_folder_name, file_name))
for old_path in old_paths:
if os.path.exists(old_path):
os.unlink(old_path)

if request.args(0) == 'profile':
db.auth_user._before_update.append(lambda s, f: delete_thumb())
db.auth_user._before_delete.append(lambda s: delete_thumb())
form = SQLFORM(...)
if form.process().accepted:
...

I think I will update Bruno's SMARTTHUMB slice.

Richard


On Mon, Jul 15, 2013 at 9:31 AM, Richard wrote:

> Hello,
>
> I am generating thumbnails with Bruno's slice :
> http://www.web2pyslices.com/slice/show/1522/generate-a-thumbnail-that-fits-in-a-box
>
> But I use "uploadseparate=True" so when I update image the derived
> thumbnails are let behind in the precedent folder, but the original image
> the one inputed by the user that serve for generating the thumbnails is
> cleared out by Field method "delete_uploaded_files()" that is call on
> update in a callback _before_update, I guess to allow the line 10045 of dal
> : "oldname = record.get(fieldname, None)" get the precedent file name
> before it get updated. I guess I need to  do the same, because I don't see
> other way to get the old file name other way...
>
> Here model :
>
> db.define_table('auth_user', ...
> Field('image','upload', uploadseparate=True, label=T('Profile image'),
> autodelete=True),
> Field('address_book_image','upload',uploadseparate=True,
> compute=lambda row: SMARTHUMB(row.image, (75,75),
> name='address_book_thumb'), autodelete=True),
> Field('profile_image','upload',uploadseparate=True, compute=lambda
> row: SMARTHUMB(row.image, (160,160), name='profile_thumb'),
> autodelete=True))
>
> So, what I thought is to do that :
>
> # Controller
>
> def delete_thumb():
> row = db(db.auth_user.id == request.args(1)).select()
> oldfoldername  =
> db.auth_user[fieldname].retrieve_file_properties(row['picture'])['path']
> oldfilename =
> db.auth_user[fieldname].retrieve_file_properties(row['picture'])['filename']
> oldpath = pjoin(oldfoldername, oldfilename)
> if exists(oldpath):
> os.unlink(oldpath)
>
> def controller_func():
> db.auth_user._before_update.append(Set.delete_thumb())
> db.auth_user._before_delete = [Set.delete_thumb()]
> form = SQLFORM(db.auth_user, request.args(1), ...)
> if form.process().accepted:
> response.flash = T('Profile updated')
> redirect(URL(c='directory',f='file',args=(auth.user_id)))
> elif form.errors:
> response.flash = T('There is error')
> else:
> response.flash = T('Fill or update the form')
>
>
> NOT TESTED
>
> Thanks for your help.
>
> Richard
>
>  --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Removing Foreign Key constraint?

2013-07-15 Thread Massimo Di Pierro
I made some simplification to your patch. Please check it in trunk. Thank 
you!


On Monday, 15 July 2013 03:51:39 UTC-5, Olivier Johner wrote:
>
> I propose this patch
>
>
> Le vendredi 12 juillet 2013 14:08:21 UTC+2, Olivier Johner a écrit :
>>
>> It's ok for the foreign key but when you archive records in another 
>> database, all fields comes in "big int" and raise a value error for string 
>> fields
>>
>> ValueError: invalid literal for long() with base 10: 'v6 box spearmint'
>>
>>
>> Le dimanche 16 juin 2013 10:28:26 UTC+2, Massimo Di Pierro a écrit :
>>>
>>> This should now be fixed in trunk. Please check it.
>>>
>>> On Thursday, 6 June 2013 08:19:35 UTC-5, Lamps902 wrote:

 To clarify, due to the SQL Foreign Key constraint (which is retained 
 when archive tables are created through auth.enable_record_versioning), 
 some of the archive database's tables still retain an association with the 
 auth_user table's id field. However, the rows with the ids on which the 
 new 
 tables depend may not necessarily be transferred from the application's 
 primary database to the archive database. Is there a way to use the DAL to 
 remove the Foreign Key constraint? Thanks.

>>>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Embed html - I'm missing a step I think

2013-07-15 Thread wdtnh
Eduardo - thanks...good grief it was staring me in the face but thanks 
again.

On Monday, July 15, 2013 9:32:20 AM UTC-4, Eduardo Cruz wrote:
>
>
> You can use response.write and pass escape=False as parameter. 
>  {{response.write("text", escape=False)}}
>
> El lunes, 15 de julio de 2013 08:43:49 UTC-4, wdtnh escribió:
>>
>> I've used XML() to escape some very basic html tags (e.g., bold, italic) 
>> I have embedded in a string that comes from a database.  In the view, I 
>> would like the affected text rendered accordingly but I'm only getting the 
>> string displayed with the tags shown e.g.,  Hi I'm bold.  I would 
>> like the text to be rendered as intended.  
>>
>> I'm guessing I'm missing a step here.  Any help would be greatly 
>> appreciated.
>>
>> thanks in advance
>>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Embed html - I'm missing a step I think

2013-07-15 Thread Eduardo Cruz

You can use response.write and pass escape=False as parameter. 
 {{response.write("text", escape=False)}}

El lunes, 15 de julio de 2013 08:43:49 UTC-4, wdtnh escribió:
>
> I've used XML() to escape some very basic html tags (e.g., bold, italic) I 
> have embedded in a string that comes from a database.  In the view, I would 
> like the affected text rendered accordingly but I'm only getting the string 
> displayed with the tags shown e.g.,  Hi I'm bold.  I would like the 
> text to be rendered as intended.  
>
> I'm guessing I'm missing a step here.  Any help would be greatly 
> appreciated.
>
> thanks in advance
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] do I need a callback ?

2013-07-15 Thread Richard
Hello,

I am generating thumbnails with Bruno's slice : 
http://www.web2pyslices.com/slice/show/1522/generate-a-thumbnail-that-fits-in-a-box

But I use "uploadseparate=True" so when I update image the derived 
thumbnails are let behind in the precedent folder, but the original image 
the one inputed by the user that serve for generating the thumbnails is 
cleared out by Field method "delete_uploaded_files()" that is call on 
update in a callback _before_update, I guess to allow the line 10045 of dal 
: "oldname = record.get(fieldname, None)" get the precedent file name 
before it get updated. I guess I need to  do the same, because I don't see 
other way to get the old file name other way... 

Here model :

db.define_table('auth_user', ...
Field('image','upload', uploadseparate=True, label=T('Profile image'), 
autodelete=True),
Field('address_book_image','upload',uploadseparate=True, compute=lambda 
row: SMARTHUMB(row.image, (75,75), name='address_book_thumb'), 
autodelete=True),
Field('profile_image','upload',uploadseparate=True, compute=lambda row: 
SMARTHUMB(row.image, (160,160), name='profile_thumb'), autodelete=True))

So, what I thought is to do that :

# Controller

def delete_thumb():
row = db(db.auth_user.id == request.args(1)).select()
oldfoldername  = 
db.auth_user[fieldname].retrieve_file_properties(row['picture'])['path']
oldfilename = 
db.auth_user[fieldname].retrieve_file_properties(row['picture'])['filename']
oldpath = pjoin(oldfoldername, oldfilename)
if exists(oldpath):
os.unlink(oldpath)

def controller_func():
db.auth_user._before_update.append(Set.delete_thumb())
db.auth_user._before_delete = [Set.delete_thumb()]
form = SQLFORM(db.auth_user, request.args(1), ...)
if form.process().accepted:
response.flash = T('Profile updated')
redirect(URL(c='directory',f='file',args=(auth.user_id)))
elif form.errors:
response.flash = T('There is error')
else:
response.flash = T('Fill or update the form')


NOT TESTED

Thanks for your help.

Richard

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Embed html - I'm missing a step I think

2013-07-15 Thread wdtnh
I've used XML() to escape some very basic html tags (e.g., bold, italic) I 
have embedded in a string that comes from a database.  In the view, I would 
like the affected text rendered accordingly but I'm only getting the string 
displayed with the tags shown e.g.,  Hi I'm bold.  I would like the 
text to be rendered as intended.  

I'm guessing I'm missing a step here.  Any help would be greatly 
appreciated.

thanks in advance

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] how to validate forms using extra data?

2013-07-15 Thread Vinicius Assef
On Mon, Jul 15, 2013 at 8:37 AM, Jim Gregory  wrote:
> is it possible without having to look up the record twice (once when creating 
> the form, the other to
> validate it)?

It's a kind of workaround, but you can put your record in request:
def test():
record = db.table[request.args(0)]
request.my_record = record
# here follows your normal code...


Then in your validation function, you simply use request.my_record


> Another option would be to pass the amount (record.total) as a hidden field
> rather than retrieve it using the record_id

What about security? I wouldn't make it.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] FPDF database image

2013-07-15 Thread Tribo Eila
Hi,

Supposed the code below:

db.define_table('person',
Field('name'),
Field('picture', 'upload')).

I'm trying to figure out, how to implement the picture field from 
database(postgreSQL) to FPDF.

Any ideas to share?

Thank You.


-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] FPDF database image

2013-07-15 Thread Tribo Eila
Hi,

Supposed the code below:

db.define_table('person',
Field('name'),
Field('picture', 'upload')).

I'm trying to figured out, how to implement the picture to retrieve from 
database(postgreSQL) to FPDF. 

Any ideas to share?

Thanks.

Newbie



-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] FPDF Report database image

2013-07-15 Thread Tribo Eila
Hi,

Supposed the code below:

db.define_table('person',
Field('name),
Field('picture', 'upload'))

I'm trying to figure out, how to implement the picture field from 
database(postgreSQL) to FPDF.

Any ideas to share?

I'm very appreciated your help.

Thank you very much.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] FPDF database image report

2013-07-15 Thread Tribo Eila
Hi,

Supposed the code below:

db.define_table('person',
Field('name),
Field('picture', 'upload'))

I'm trying to figure out, how to implement the picture field from 
database(postgreSQL) to FPDF.

Any ideas to share?

I'm very appreciated your help.

Thank you very much.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Local and AD authentication in one login form

2013-07-15 Thread Koen Vanhees
Dear,

For a project I need to build an application where access control - 
obviously - is quite important.
I would like to have a login form where one can authenticate with AD, and 
still have an option to have local user authentication.
What's the best way to set this up?

Many thanks in advance!

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] AD Authentication issues

2013-07-15 Thread Koen Vanhees
All,

I'm having some issues with integrating Active Directory authentication in 
my app.
Although telnet to the domain controller works, also tcpdump seems to send 
and receive information to the domain controller, Logging level set 
to"debug" doesn't reveal much more:
DEBUG:web2py.auth.ldap_auth:mode: [ad] manage_user: [False] custom_scope: 
[subtree] manage_groups: [False]
INFO:web2py.auth.ldap_auth:[192.168.1.115] Initialize ldap connection

Any hints are very welcome...

Cheers,
Koen

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Local and AD authentication in one form

2013-07-15 Thread Koen Vanhees
Dear,

(I might have posted this question before, but I can't seem to find it 
back, so if I missed it, I apologize).
I am building a web application where AD authentication as well as local 
authentication should be possible.
What's the best practice to set this up in one form?  And to handle 
authorization etc...?

Thanks in advance!

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] how to validate forms using extra data?

2013-07-15 Thread Jim Gregory
You're right, either method would work.  But is it possible without having 
to look up the record twice (once when creating the form, the other to 
validate it)?  

Another option would be to pass the amount (record.total) as a hidden field 
rather than retrieve it using the record_id

-Jim 

On Monday, July 15, 2013 6:11:52 AM UTC-5, viniciusban wrote:
>
> Yes, there are some solutions and you gave one of them: create the 
> record id as a hidden field in your form. 
>
> Other solution can be using request.args(0) in your _validate_form() 
> function. 
>
> On Mon, Jul 15, 2013 at 8:01 AM, Jim Gregory 
> > 
> wrote: 
> > I have a form with five text input boxes: 
> > 
> > form = FORM(*[INPUT('amount-%s' % i, _type='number') for i in range(5)], 
> > INPUT(_type='submit')) 
> > 
> > The sum of these input boxes must equal the value of a field in a 
> database 
> > record. 
> > 
> > I would like to pass the database record as a parameter to the 
> onvalidation 
> > callback of the form, but as I understand it, this is not possible--the 
> > onvalidation function can only be passed one argument, the function 
> itself. 
> > 
> > So, instead, I have written a second function to check validation after 
> the 
> > form passes its initial validation: 
> > 
> > def _validate_form(form, record): 
> > total = 0.0 
> > for f in request.vars: 
> > if request.vars[f].startswith('amount-') and request.vars[f] != 
> '': 
> > total += float(request.vars[f]) 
> > if total != record.total: 
> > for f in request.vars: 
> > if request.vars[f].startswith('amount-') and request.vars[f] != 
> '': 
> > form.errors[f] = 'total of amounts must equal record total' 
> > return form.errors 
> > 
> > def test(): 
> > record = db.table[request.args(0)] 
> > form = FORM(*[INPUT('amount-%s' % i, _type='number') for i in 
> > range(5)],INPUT(_type='submit')) 
> > if form.validate(): 
> > form.errors = _validate_form(form, record) 
> > if not form.errors: 
> > redirect('next_page') 
> > return form 
> > 
> > The trouble I am having is the test--'form.errors' returns True (and 
> hence 
> > 'not form.errors' returns False) even when _validate_form returns an 
> empty 
> > form.errors Storage object. 
> > 
> > I don't understand why it does.  How should I test for this condition 
> > instead? 
> > 
> > Is there another way I could do this using the onvalidation function, 
> other 
> > than passing the record id as a hidden form field and doing the record 
> > selection in the validation function?  (In my actual application, the 
> record 
> > must be selected before the form is created.) 
> > 
> > -- 
> > 
> > --- 
> > You received this message because you are subscribed to the Google 
> Groups 
> > "web2py-users" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> an 
> > email to web2py+un...@googlegroups.com . 
> > For more options, visit https://groups.google.com/groups/opt_out. 
> > 
> > 
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] how to validate forms using extra data?

2013-07-15 Thread Vinicius Assef
Yes, there are some solutions and you gave one of them: create the
record id as a hidden field in your form.

Other solution can be using request.args(0) in your _validate_form() function.

On Mon, Jul 15, 2013 at 8:01 AM, Jim Gregory  wrote:
> I have a form with five text input boxes:
>
> form = FORM(*[INPUT('amount-%s' % i, _type='number') for i in range(5)],
> INPUT(_type='submit'))
>
> The sum of these input boxes must equal the value of a field in a database
> record.
>
> I would like to pass the database record as a parameter to the onvalidation
> callback of the form, but as I understand it, this is not possible--the
> onvalidation function can only be passed one argument, the function itself.
>
> So, instead, I have written a second function to check validation after the
> form passes its initial validation:
>
> def _validate_form(form, record):
> total = 0.0
> for f in request.vars:
> if request.vars[f].startswith('amount-') and request.vars[f] != '':
> total += float(request.vars[f])
> if total != record.total:
> for f in request.vars:
> if request.vars[f].startswith('amount-') and request.vars[f] != '':
> form.errors[f] = 'total of amounts must equal record total'
> return form.errors
>
> def test():
> record = db.table[request.args(0)]
> form = FORM(*[INPUT('amount-%s' % i, _type='number') for i in
> range(5)],INPUT(_type='submit'))
> if form.validate():
> form.errors = _validate_form(form, record)
> if not form.errors:
> redirect('next_page')
> return form
>
> The trouble I am having is the test--'form.errors' returns True (and hence
> 'not form.errors' returns False) even when _validate_form returns an empty
> form.errors Storage object.
>
> I don't understand why it does.  How should I test for this condition
> instead?
>
> Is there another way I could do this using the onvalidation function, other
> than passing the record id as a hidden form field and doing the record
> selection in the validation function?  (In my actual application, the record
> must be selected before the form is created.)
>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: How to control smartgrid search widget height and width?

2013-07-15 Thread Sarbjit singh
I am very new to web2py, appreciate if you can provide me a small example.

Thanks 
Sarbjit

On Monday, July 15, 2013 4:36:02 PM UTC+5:30, Niphlod wrote:
>
> As any other customization in HTML, use the css, Luke!
> Default styles should be from 
> https://github.com/web2py/web2py/blob/master/applications/welcome/static/css/web2py.css#L192
>  down
>
>
> Il giorno lunedì 15 luglio 2013 10:27:35 UTC+2, Sarbjit singh ha scritto:
>>
>> I am using default searchwidget available in SMARTGRID and want to 
>> customize the size of search entry window. I am having a large number of 
>> database options which can be used for searching records from db, so I want 
>> to make my search window long enough (increase both width and height) such 
>> that the search query can be visible in one go.
>>
>> Can some one please point me on how to do it?
>>
>> -Sarbjit
>>
>>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: How to control smartgrid search widget height and width?

2013-07-15 Thread Niphlod
As any other customization in HTML, use the css, Luke!
Default styles should be from 
https://github.com/web2py/web2py/blob/master/applications/welcome/static/css/web2py.css#L192
 down


Il giorno lunedì 15 luglio 2013 10:27:35 UTC+2, Sarbjit singh ha scritto:
>
> I am using default searchwidget available in SMARTGRID and want to 
> customize the size of search entry window. I am having a large number of 
> database options which can be used for searching records from db, so I want 
> to make my search window long enough (increase both width and height) such 
> that the search query can be visible in one go.
>
> Can some one please point me on how to do it?
>
> -Sarbjit
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: How to use labels as elements inside the search widget of smartgrid?

2013-07-15 Thread Niphlod
there's no ability to "disguise" the column names ATM. 

Il giorno lunedì 15 luglio 2013 13:00:05 UTC+2, Sarbjit singh ha scritto:
>
> I am using smartgrid to create a grid for the records present in the 
> database. I have labelled all the database elements as :
>
> db.mytable.myname.label = 'Name'
>
> Now in the grid which is generated does shows "Name" in the table header 
> and in the drop-down which is used to build search queries. Now this is 
> fine and works like as expected, but when I hit the "New" in the search 
> widget - it shows the underlying database name and its elements in search 
> field :
>
> mytable.myname == 'John'
>
> I do not want to expose the variable names and table name to the user's. 
> So I just want to know if this is indeed possible using web2py. 
>
> Also, I am seeing the same behavior when I use the export csv. 
>
> -Sarbjit
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] how to validate forms using extra data?

2013-07-15 Thread Jim Gregory
I have a form with five text input boxes:

form = FORM(*[INPUT('amount-%s' % i, _type='number') for i in range(5)], 
INPUT(_type='submit'))

The sum of these input boxes must equal the value of a field in a database 
record.

I would like to pass the database record as a parameter to the onvalidation 
callback of the form, but as I understand it, this is not possible--the 
onvalidation function can only be passed one argument, the function itself.

So, instead, I have written a second function to check validation after the 
form passes its initial validation:

def _validate_form(form, record):
total = 0.0
for f in request.vars:
if request.vars[f].startswith('amount-') and request.vars[f] != '':
total += float(request.vars[f])
if total != record.total:
for f in request.vars:
if request.vars[f].startswith('amount-') and request.vars[f] != '':
form.errors[f] = 'total of amounts must equal record total'
return form.errors

def test():
record = db.table[request.args(0)]
form = FORM(*[INPUT('amount-%s' % i, _type='number') for i in 
range(5)],INPUT(_type='submit'))
if form.validate():
form.errors = _validate_form(form, record)
if not form.errors:
redirect('next_page')
return form

The trouble I am having is the test--'form.errors' returns True (and hence 
'not form.errors' returns False) even when _validate_form returns an empty 
form.errors Storage object.

I don't understand why it does.  How should I test for this condition 
instead?  

Is there another way I could do this using the onvalidation function, other 
than passing the record id as a hidden form field and doing the record 
selection in the validation function?  (In my actual application, the 
record must be selected before the form is created.) 

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] How to use labels as elements inside the search widget of smartgrid?

2013-07-15 Thread Sarbjit singh
I am using smartgrid to create a grid for the records present in the 
database. I have labelled all the database elements as :

db.mytable.myname.label = 'Name'

Now in the grid which is generated does shows "Name" in the table header 
and in the drop-down which is used to build search queries. Now this is 
fine and works like as expected, but when I hit the "New" in the search 
widget - it shows the underlying database name and its elements in search 
field :

mytable.myname == 'John'

I do not want to expose the variable names and table name to the user's. So 
I just want to know if this is indeed possible using web2py. 

Also, I am seeing the same behavior when I use the export csv. 

-Sarbjit

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Smartgrid custom form problem

2013-07-15 Thread Sarbjit singh
Thanks a lot.

It worked :)

On Monday, July 15, 2013 2:16:05 PM UTC+5:30, Massimo Di Pierro wrote:
>
> Should be:
>
> {extend 'layout.html'}}
> {{if grid.update_form:}}
> {{=grid.update_form.custom.begin}}
> Name of object {{=grid .update_form
> .custom.widget.name }}
> {{=grid.update_form.custom.submit}}
> {{=grid.update_form.custom.end}}
> {{else:}}
> {{=grid}}
> {{pass}}
>
> On Sunday, 14 July 2013 23:14:03 UTC-5, Sarbjit singh wrote:
>>
>> Hi,
>>
>> I am using customized form for adding records into database and using 
>> smartgrid to view/edit the records inserted in the database. Since, I am 
>> using the customized form for adding records into the database, I want to 
>> use the same layout for Edit operation (from SMARTGRID).
>>
>> To achieve this, I added the check in the controller as :
>>
>> {extend 'layout.html'}}
>> {{if 'edit' in request.args:}}
>> {{=grid.custom.begin}}
>> Name of object {{=grid.custom.widget.name}}
>> {{=grid.custom.submit}}
>> {{=grid.custom.end}}
>> {{else:}}
>> {{=grid}}
>> {{pass}}
>>
>> But with this code, I am getting error. Can someone please help me on how 
>> to use custom form with SMARTGRID
>>
>> -Sarbjit
>>
>>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Removing Foreign Key constraint?

2013-07-15 Thread Olivier Johner
I propose this patch


Le vendredi 12 juillet 2013 14:08:21 UTC+2, Olivier Johner a écrit :
>
> It's ok for the foreign key but when you archive records in another 
> database, all fields comes in "big int" and raise a value error for string 
> fields
>
> ValueError: invalid literal for long() with base 10: 'v6 box spearmint'
>
>
> Le dimanche 16 juin 2013 10:28:26 UTC+2, Massimo Di Pierro a écrit :
>>
>> This should now be fixed in trunk. Please check it.
>>
>> On Thursday, 6 June 2013 08:19:35 UTC-5, Lamps902 wrote:
>>>
>>> To clarify, due to the SQL Foreign Key constraint (which is retained 
>>> when archive tables are created through auth.enable_record_versioning), 
>>> some of the archive database's tables still retain an association with the 
>>> auth_user table's id field. However, the rows with the ids on which the new 
>>> tables depend may not necessarily be transferred from the application's 
>>> primary database to the archive database. Is there a way to use the DAL to 
>>> remove the Foreign Key constraint? Thanks.
>>>
>>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


diff --git a/gluon/dal.py b/gluon/dal.py
index af20494..7671cd7 100644
--- a/gluon/dal.py
+++ b/gluon/dal.py
@@ -8307,8 +8307,11 @@ class Table(object):
 field_type = self if same_db else 'bigint'
 clones = []
 for field in self:
+fk = False
+if field.type.find('reference') != -1:
+fk = True if not same_db else False
 clones.append(field.clone(
-unique=False, type=field.type if same_db else 'bigint'))
+unique=False, type=field.type if (same_db or not fk) else 
'bigint'))
 archive_db.define_table(
 archive_name, Field(current_record,field_type), *clones)
 self._before_update.append(

[web2py] Re: Smartgrid custom form problem

2013-07-15 Thread Massimo Di Pierro
Should be:

{extend 'layout.html'}}
{{if grid.update_form:}}
{{=grid.update_form.custom.begin}}
Name of object {{=grid .update_form
.custom.widget.name }}
{{=grid.update_form.custom.submit}}
{{=grid.update_form.custom.end}}
{{else:}}
{{=grid}}
{{pass}}

On Sunday, 14 July 2013 23:14:03 UTC-5, Sarbjit singh wrote:
>
> Hi,
>
> I am using customized form for adding records into database and using 
> smartgrid to view/edit the records inserted in the database. Since, I am 
> using the customized form for adding records into the database, I want to 
> use the same layout for Edit operation (from SMARTGRID).
>
> To achieve this, I added the check in the controller as :
>
> {extend 'layout.html'}}
> {{if 'edit' in request.args:}}
> {{=grid.custom.begin}}
> Name of object {{=grid.custom.widget.name}}
> {{=grid.custom.submit}}
> {{=grid.custom.end}}
> {{else:}}
> {{=grid}}
> {{pass}}
>
> But with this code, I am getting error. Can someone please help me on how 
> to use custom form with SMARTGRID
>
> -Sarbjit
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: How to handle multiple domains with the same application

2013-07-15 Thread Massimo Di Pierro
Yes. For example I have this in my routes.py file:

routes_in=[
('^.*:https?://(www.)?fermiqcd.com:\w+ /','/fermiqcd'),
('^.*:https?://(www.)?experts4solutions.com:\w+ /','/e4s'),
('^.*:https?://evote.experts4solutions.com:\w+ /','/evote'),
('^.*:https?://(www.)?ptolincoln.org:\w+ /','/pto'),
('^.*:https://(.*)election.name:\w+ /','/evote'),
('/','/examples/default/index'),
('/robots.txt','/examples/static/robots.txt'),
('/favicon.ico','/examples/static/favicon.ico')]

It tells how to map paths (for each domain) into which web2py application.



On Sunday, 14 July 2013 18:22:31 UTC-5, Marcio Andrey Oliveira wrote:
>
> Hi.
>
> Currently I have 3 arcade sites: 1 with all kinds of games, 1 with only 
> girls games and another one with only escaping games.
>
> Each site is running in a separated script, and worst than that is that I 
> have some games in girls game site and on escaping games sites that exist 
> on general arcade site. It means I'm expending database and disk space with 
> duplicated date.
>
> I want to make one application that will receive requests from all domains 
> and according to the domain, it will show a different look and feel with 
> its respective games.
>
> How do I do it in web2py? I mean, how do I handle resources based in the 
> domain user typed in browser? 
>
> Regards.
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Debugging web2py with pycharm ... how?

2013-07-15 Thread Tim Richardson
Wiith pycham 2.7.3, how can I debug as per pydev?
Ie launch python web2py.py via a debug configuration ... pydev enters 
breakpoints in controllers & modules but when I repeat this approach with 
pycharm, the breakpoints never break.


-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Using ROWID function as id field in sqlite tables

2013-07-15 Thread Massimo Di Pierro
yes this is not throughly tested but as far as we know it works. You can 
use any existing field as 'id'

On Sunday, 14 July 2013 18:05:03 UTC-5, Woody wrote:
>
> This may be something that is known by people with more experience than 
> me, but it took me a lot of experimenting to figure it out, so I thought I 
> would post it here so others will find it.
>
> I have legacy sqlite tables that do not have an id field.  This makes it 
> difficult to update them using SQLFORM.
>
> ROWID is a hidden auto-increment integer field that's included in all 
> sqlite tables.  You can make ROWID explicit by declaring it as the first 
> field in a table definition, then you can assign it the 'id' alias.
>
> Here's an example:
>
> db.define_table('my_sqlite_table',
> Field('ROWID', 'id'),
> Field('some_field', 'string'),
> Field('some_other_field', 'integer'),
> 
> migrate=False)
>
> You can then use 'id' as a field name just as if your table had an actual 
> id field defined in the underlying table.  As far as I can tell, this hack 
> works without any problems.  The use of the 'id' alias is documented, but 
>  I haven't seen the use of 'ROWID' with the alias discussed.  This might be 
> something that could be tested and added to the documentation.
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: How to insert line breaks in table cell created by a virtual field

2013-07-15 Thread Massimo Di Pierro
Try this:

db.table.field = Field.Virtual('alert_time', 
lambda row: XML(str() + ' hours' + str()))

On Sunday, 14 July 2013 17:40:28 UTC-5, Woody wrote:
>
> I have a virtual field that concatenates 2 fields like this:
>
> Field.Virtual('alert_time', 
> lambda row: (str( integer>) + ' hours | ' + str())
>
 

>
> The result goes into a table cell and looks something like this:  "8 hours 
> 2013-07-14 09:10:20"
>
> I want to force  line breaks so that it will look like this
>  8 hours
>   2013-07-14
> 09:10:20
>
> I tried inserting line breaks using /n or  in the text like this:
>
> lambda row: (str() + ' hours/n' 
> + str())
>
> but they printed out as string literals in the table.  How can I format 
> the text for this cell?
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] How to control smartgrid search widget height and width?

2013-07-15 Thread Sarbjit singh
I am using default searchwidget available in SMARTGRID and want to 
customize the size of search entry window. I am having a large number of 
database options which can be used for searching records from db, so I want 
to make my search window long enough (increase both width and height) such 
that the search query can be visible in one go.

Can some one please point me on how to do it?

-Sarbjit

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: web2py roadmap

2013-07-15 Thread Niphlod
yep... asking here. Sorry but we're trying to keep things on order and 
can't allow anyone to add things other than votes ^_^ 

Il giorno lunedì 15 luglio 2013 08:02:10 UTC+2, David Marko ha scritto:
>
> Is there  a way how to add something to wishlist?
>
> Dne neděle, 14. července 2013 22:30:05 UTC+2 Niphlod napsal(a):
>>
>> web2py's developers work often "behind the curtain" and users are not 
>> able to see what they're working on. Historically we tracked down 
>> feature-requests and todo-lists on google code, but it's a nightmare to 
>> track them and work with it efficiently.
>>
>> On a nice tip received by a power web2py user, we (developers) decided to 
>> create something more readable to give us (developers AND users) a nice 
>> representation on what's going on.
>>
>> Please welcome the official trello board for web2py's roadmap : 
>> https://trello.com/b/d3aqBbBl
>>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.