[web2py] Re: How to identify the active .table files

2013-08-18 Thread at
Thank you Niphlod.

If connection string is same, can we generate .table files in one server 
and then use them in other server?

Actually we've two web2py servers (active & pasive) pointing to single 
database server and we need to sync the database folder on both servers 
when db model is modified.

Regards,
AT

On Saturday, 17 August 2013 16:48:07 UTC+5, Niphlod wrote:
>
> the part preceding the _options is the md5 of the connection string. If 
> you want a quick and dirty method, backup those files to another dir, set 
> fake_migrate=True and let web2py recreate the "current" file.
>
> On Saturday, August 17, 2013 12:08:10 PM UTC+2, at wrote:
>>
>> Hi,
>>
>> In databases folder of a running web2py application, there are four 
>> .table files for the same table. How can be identified that which of these 
>> files are currently being used by the application?
>>
>> 103902c891e80b37c5ca0f9d021b98e8_option.table
>> 13012917802f9750f7e6aec22cf2fb30_option.table
>> c5f365ce982338d5733d61d0ac11ded3_option.table
>> eee02c492ba9ed34049a9ff8dc72b10c_option.table
>>
>> Thanks & Regards,
>> AT
>>
>

-- 

--- 
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: Date search on sqlform.grid not working

2013-08-18 Thread Massimo Di Pierro
Good point. The search is performed in the database format which is ISO 
(Y/m/d). The grid is not smart enough to apply local settings (custom data 
formats) to the search field. You may want to open a ticket about this and 
we'll see what we can do.

On Saturday, 17 August 2013 12:43:23 UTC-5, Leonardo Pires Felix wrote:
>
> I've found something, when i do the search using the date picker, it 
> returns me in the format of the translation file("%d/%m/%Y"), but when use 
> like this to do the search, it returns nothing or something not expected. 
> But if i mannually change the format from the search on the sqlform.grid to 
> "%Y/%m/%d" it works out. How do to the sqlform.grid recognize the format 
> that i want to use on the search("%d/%m/%Y") ?
>
>

-- 

--- 
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: urlify - no char mapping

2013-08-18 Thread Massimo Di Pierro
Look ate the source code of urlify:
https://github.com/web2py/web2py/blob/master/gluon/validators.py#L2525

If you can suggest improvements I will happy to include them. I guess the 
problem is here:

https://github.com/web2py/web2py/blob/master/gluon/validators.py#L2534

Massimo

On Friday, 16 August 2013 07:39:50 UTC-5, lesssugar wrote:
>
> I'm using the following module to convert my urls:
>
>
> http://pydoc.net/Python/redsolutioncms.django-hex-storage/0.1.1/pinyin.urlify/
>
> I have urlify.py (main function) and maps.py (chars mapping) in my 
> /modules. I test it in one of my views, simply trying to print the 
> urlify-ed value in the console:
>
> {{from urlify import urlify}}
> {{print urlify(u"łźć ęćm")}}
>
> I get "aaa-aaa", so basically there's no mapping done and I have no idea 
> 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: Send and save as draft email forms

2013-08-18 Thread Massimo Di Pierro
Why should web2py include mail storage? It looks more like an app to me 
than a core feature.

On Saturday, 17 August 2013 07:54:37 UTC-5, Alan Etkin wrote:
>
> I have opened an issue requesting the mail storage feature.
>
> https://groups.google.com/d/msg/web2py/WrFGJhGI8ds/q8SvGEuZwZUJ
>

-- 

--- 
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: MOD_WSGI and web2py doesn't allow url below root

2013-08-18 Thread Massimo Di Pierro
I would use Apache. Mostly because it is a little faster. 

On Saturday, 17 August 2013 16:48:38 UTC-5, jonten wrote:
>
> Hi Massimo,
>
> I am just curious to know if it is better to modify BASE in routes.py than 
> using the config below in Apache vhost config instead of WSGIScriptAlias? 
> Or if it is equvivalent:
>
> WSGIScriptAliasMatch ^/myapp.* /var/www/web2py/wsgihandler.py
>
> Best regards,
> //Jon
>
>

-- 

--- 
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: MOD_WSGI and web2py doesn't allow url below root

2013-08-18 Thread Massimo Di Pierro
P.S. Also I would make a distinction on whether the mapping is done to 
remove a BASE (use apache) for aesthetic reasons (also use Apache) or for 
functional reasons (use routes.py).

By functional reasons I man that the app would break without the mapping. 
If the app would break than the mapping belongs to the web2py level 
(routes.py or app level routes.py).

On Sunday, 18 August 2013 03:02:47 UTC-5, Massimo Di Pierro wrote:
>
> I would use Apache. Mostly because it is a little faster. 
>
> On Saturday, 17 August 2013 16:48:38 UTC-5, jonten wrote:
>>
>> Hi Massimo,
>>
>> I am just curious to know if it is better to modify BASE in routes.py 
>> than using the config below in Apache vhost config instead of 
>> WSGIScriptAlias? Or if it is equvivalent:
>>
>> WSGIScriptAliasMatch ^/myapp.* /var/www/web2py/wsgihandler.py
>>
>> Best regards,
>> //Jon
>>
>>

-- 

--- 
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: db.mytable.myfield.contains() gives an error Query Not Supported: parser stack overflow

2013-08-18 Thread Massimo Di Pierro
I think by this:

x = ['a', 'b', 'c', ...]
queries.append(db.mytable.myfield.contains(x))

you mean:

x = ['a', 'b', 'c', ...]
queries.append(db.mytable.myfield.belongs(x))

You cannot pass a list to contains. That may part of the problem.
there may be other problems. Can you show more code or explain what the 
query is supposed to do?

Massimo


On Saturday, 17 August 2013 21:11:52 UTC-5, dave wrote:
>
> I guess nobody encountered this issue before?
>
> On Thursday, August 15, 2013 11:59:31 AM UTC-7, dave wrote:
>>
>> .
>> .
>> .
>> x = ['a', 'b', 'c', ...]
>> queries.append(db.mytable.myfield.contains(x))
>> query = reduce(lambda a,b:(a&b),queries)
>> grid = SQLFORM.grid(query, ...)
>>
>> return (grid=grid)
>>
>> gives an error of "Query Not Supported: parser stack overflow", if the 
>> list x has too many values, like around 100 or a 1000, I suspect its an 
>> sqlite limitation? can anyone suggest another succinct way of passing a 
>> list to a contain like operator or method. 
>>
>

-- 

--- 
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] Unexpected redirect to login?_next

2013-08-18 Thread Annet
I have a custom registration process. Registration forms are stored in the 
database, and retrieved 
in a function called cmsadmin/register 

http://127.0.0.1:8000/mock/cmsadmin/register

This functions lists the registrations forms and  a link to the individual 
form.

http://127.0.0.1:8000/mock/cmsadmin/registerForm/1
http://127.0.0.1:8000/mock/cmsadmin/registerForm/2
http://127.0.0.1:8000/mock/cmsadmin/registerForm/3

etc.

When I click the registerForm link I am redirected to a login page instead 
of to the function
that processes the registration forms:

http://127.0.0.1:8000/mock/default/user/login?_next=/mock/cmsadmin/registerForm/1
http://127.0.0.1:8000/mock/default/user/login?_next=/mock/cmsadmin/registerForm/2
http://127.0.0.1:8000/mock/default/user/login?_next=/mock/cmsadmin/registerForm/3

What is the mechanism in web2py causing this behaviour. And how do I bypass 
it?


Kind 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: urlify - no char mapping

2013-08-18 Thread Niphlod
indeed, "our" urlify doesn't work with "ideograms" (sorry, I'm totally no 
expert in oriental languages).
The original posted solution takes care of "translating" 

派森是好物
to
pai-sen-shi-hao-wu


we can add the feature looking at other similar projects, but we need 
someone that has a solid knowledge of oriental (and turkish, polish, 
latvian, polish, czech) to write tests.

On Sunday, August 18, 2013 10:00:32 AM UTC+2, Massimo Di Pierro wrote:
>
> Look ate the source code of urlify:
> https://github.com/web2py/web2py/blob/master/gluon/validators.py#L2525
>
> If you can suggest improvements I will happy to include them. I guess the 
> problem is here:
>
> https://github.com/web2py/web2py/blob/master/gluon/validators.py#L2534
>
> Massimo
>
> On Friday, 16 August 2013 07:39:50 UTC-5, lesssugar wrote:
>>
>> I'm using the following module to convert my urls:
>>
>>
>> http://pydoc.net/Python/redsolutioncms.django-hex-storage/0.1.1/pinyin.urlify/
>>
>> I have urlify.py (main function) and maps.py (chars mapping) in my 
>> /modules. I test it in one of my views, simply trying to print the 
>> urlify-ed value in the console:
>>
>> {{from urlify import urlify}}
>> {{print urlify(u"łźć ęćm")}}
>>
>> I get "aaa-aaa", so basically there's no mapping done and I have no idea 
>> 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 identify the active .table files

2013-08-18 Thread Niphlod

>
>
> If connection string is same, can we generate .table files in one server 
> and then use them in other server?
>
> of course
 

> Actually we've two web2py servers (active & pasive) pointing to single 
> database server and we need to sync the database folder on both servers 
> when db model is modified.
>
> well, you can keep it "clean" on the master and then synchronize the 
folder to the passive. 
BTW, if there are multiple filenames for the same table you don't need to 
worry, web2py will only pickup the one needed. You're fine as long as the 
same files on the "working" version are the same in the other one.
Also, .table files are just needed for actual migrations, so remember to 
set migrate=False if you don't change any table definition. 
Once the migration has been done and you set migrate=False, you can totally 
live with an empty databases/ folder because .table files are not necessary.
My point being: depending on your architecture, you may decide to have 
migration happening only on server1 (where you keep your databases/ folder 
"filled") and have server2 with migrate=False with no .table files 
whatsoever.

-- 

--- 
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: urlify - no char mapping

2013-08-18 Thread lesssugar
Docs site specifies *IS_SLUG.urlify.__dict__ *and *IS_SLUG.urlify.func_dict. 
*However, I'm not sure how to work with dictionary here.

Can I e.g. do something like this:

IS_SLUG.urlify(string_to_convert, mapping_dictionary)

and simply tell the function which set of key-value pairs it should use?

On Sunday, August 18, 2013 11:23:35 AM UTC+2, Niphlod wrote:
>
> indeed, "our" urlify doesn't work with "ideograms" (sorry, I'm totally no 
> expert in oriental languages).
> The original posted solution takes care of "translating" 
>
> 派森是好物
> to
> pai-sen-shi-hao-wu
>
>
> we can add the feature looking at other similar projects, but we need 
> someone that has a solid knowledge of oriental (and turkish, polish, 
> latvian, polish, czech) to write tests.
>
> On Sunday, August 18, 2013 10:00:32 AM UTC+2, Massimo Di Pierro wrote:
>>
>> Look ate the source code of urlify:
>> https://github.com/web2py/web2py/blob/master/gluon/validators.py#L2525
>>
>> If you can suggest improvements I will happy to include them. I guess the 
>> problem is here:
>>
>> https://github.com/web2py/web2py/blob/master/gluon/validators.py#L2534
>>
>> Massimo
>>
>> On Friday, 16 August 2013 07:39:50 UTC-5, lesssugar wrote:
>>>
>>> I'm using the following module to convert my urls:
>>>
>>>
>>> http://pydoc.net/Python/redsolutioncms.django-hex-storage/0.1.1/pinyin.urlify/
>>>
>>> I have urlify.py (main function) and maps.py (chars mapping) in my 
>>> /modules. I test it in one of my views, simply trying to print the 
>>> urlify-ed value in the console:
>>>
>>> {{from urlify import urlify}}
>>> {{print urlify(u"łźć ęćm")}}
>>>
>>> I get "aaa-aaa", so basically there's no mapping done and I have no idea 
>>> 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.


Re: [web2py] Re: sharing my d3.js experiments with web2py community

2013-08-18 Thread David Lypka
OK I ran your updated samples.
Many thanks - I will try to use some of these techniques.



On Sat, Aug 17, 2013 at 10:41 PM, greaneym  wrote:

>
> Dave,
>
> I put an updated set of d3.js examples on my github page. Try
> the web2py-1.app.d3anim.w2p  which contains more examples, including
> "overlayed on a page".
>
> You can change these examples by adding your own html files  by
> "extending" or "including" html files, and you can read more about this in
> the web2py manual.
>
> Also, this should help you with svg placement,
>
> http://alistapart.com/article/using-svg-for-flexible-scalable-and-fun-backgrounds-part-i
>   (and part-2)
>
> Margaret
> On Friday, August 16, 2013 11:07:33 AM UTC-5, dlypka wrote:
>
>> Hi Margaret:
>>
>> OK I played with your samples.
>> Great technology.
>> I would like to see such effects overlayed onto an existing page.
>>
>> - Dave Lypka.
>>
>> On Saturday, August 10, 2013 7:47:00 PM UTC-5, greaneym wrote:
>>>
>>>
>>> Hi there,
>>>
>>> I am sharing my experiments with D3.js this week. It's Geek Week,
>>> according to Google and I tried some animations with svg and images.
>>>
>>>
>>> These are at
>>> htttps://github.com/greaneym/**d3anim
>>>
>>>
>>> I tried adding them to the slices page but it didn't look like that
>>> worked.  Also, please add a female avatar (generic) picture in the
>>> registration page (that would be nice).
>>>
>>>
>>> Margaret
>>>
>>>
>>>  --
>
> ---
> 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/ICn_TAkjync/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] Re: Load content from a text file

2013-08-18 Thread Jim Gregory
I'm not an expert in web2py, but this one approach I think should work
for your application.  If others have better ways of doing it, please
share them:

def readfile():
'''
returns the file to be read
'''
response.view = '/path/to/file_to_be_read.txt'
return locals()

def writefile():
'''
writes the values of the form in basic, unescaped CSV format
''' 
form = SQLFORM.factory(
Field('name'),
Field('choice', requires=IS_IN_SET(['1','2','3'], zero=None)),
) 
if form.validate():
fh = open('path/to/file_to_write_to.txt', 'w')
fh.write(','.join(form.vars.values()))
fh.close()
response.flash = 'Your data has been submitted'
return dict(form=form)

It sounds like in your application, you are reading the serial port at
fixed periodic intervals and writing the data to a file.  If you only
need to read or write to it when a user requests a page, this is what I
was suggesting instead:

def readdata():
'''
read data from serial port and return it in a view
see the Python PySerial module documentation for details
'''
import serial
try:
ser = serial.Serial('/dev/ttyS1', 19200, timeout=1)
data = ser.readline()   # read a '\n' terminated line
ser.close()
except:
data = 'cannot read serial port'
return dict(data=data)

writing to the serial port would be just as easy:

def writedata():
'''
writes form values in basic, unescaped CSV to the serial port
''' 
import serial
form = SQLFORM.factory(
Field('name'),
Field('choice', requires=IS_IN_SET(['1','2','3'], zero=None)),
) 
if form.validate():
try:
ser = serial.Serial('/dev/ttyS1', 19200, timeout=1)
ser.write(','.join(form.vars.values()))
ser.close()
response.flash = 'Your data has been written'
except:
response.flash = 'Cannot write to serial port'
return dict(form=form)

HTH,

-Jim 

- Kenneth Lundström  wrote:-

> Hello,
> 
> only one max two clients at a time will access this page. I don't
> even see why two clients would be accesing this page if not a
> supervisor wants to check on the progress of an worker.
> 
> Jim, not quite sure how to do what you suggest. The serial
> communication is using an special protocol that the app reads and
> creates an text file from.
> 
> The app stores also everything in the database but I thought it
> would be more efficient for this page to get the info from an text
> file. There will be many other pages that will be using mobile
> jquery with an normal menu that reads data from the database, but
> this one special page will be just a blank page showing the content
> of the file if I can't find out how to reload just the part of the
> page that shows the text file. Was thinking using PHP to show that
> page.
> 
> 
> Kenneth
> 
> 
> >Now many clients need to access this at one time? The issue is the
> >workload on the pi.
> >
> >On Friday, 16 August 2013 17:40:29 UTC-5, Kenneth wrote:
> >
> >Hello everyone,
> >
> >I'm planing on running web2py on an Raspberry Pi. On the computer
> >there will also be an app that listens on the serial port and
> >writes the results into an text file.
> >
> >I'd like to create an extremly simple page where only the content
> >of the file is shown and having the page to reload like once every
> >second. This page will be shown from mobile ones or tablets over
> >GPRS or 3G.
> >
> >Is it possible to create an page so every reload doesn't
> >re-execute the controller and models just re-reads the text file
> >and shows it.
> >
> >To controll that app I'd like to sends commands by writing them
> >into an text file that the app reads. This shouldn't be too hard?
> >
> >
> >Kenneth
> >
> >-- 
> >
> >---
> >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 a topic
> in the Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit 
> https://groups.google.com/d/topic/web2py/_jYbslU46R4/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.


[web2py] Re: urlify - no char mapping

2013-08-18 Thread Niphlod
ATM there are no dict mappings available for the function included in 
web2py. 
You can use the function directly with IS_SLUG()('whatever_string') in 
which case you have a tuple returned with (result, error) or directly with 
IS_SLUG().urlify('whatever_string') which returns only the result as a 
string. There are only two parameters, maxlen (it truncates the string to n 
chars) and keep_underscores (by default is false, so every _ gets 
translated to a - (hypen))



On Sunday, August 18, 2013 12:17:20 PM UTC+2, lesssugar wrote:
>
> Docs site specifies *IS_SLUG.urlify.__dict__ *and *IS_SLUG.urlify.func_dict. 
> *However, I'm not sure how to work with dictionary here.
>
> Can I e.g. do something like this:
>
> IS_SLUG.urlify(string_to_convert, mapping_dictionary)
>
> and simply tell the function which set of key-value pairs it should use?
>
> On Sunday, August 18, 2013 11:23:35 AM UTC+2, Niphlod wrote:
>>
>> indeed, "our" urlify doesn't work with "ideograms" (sorry, I'm totally no 
>> expert in oriental languages).
>> The original posted solution takes care of "translating" 
>>
>> 派森是好物
>> to
>> pai-sen-shi-hao-wu
>>
>>
>> we can add the feature looking at other similar projects, but we need 
>> someone that has a solid knowledge of oriental (and turkish, polish, 
>> latvian, polish, czech) to write tests.
>>
>> On Sunday, August 18, 2013 10:00:32 AM UTC+2, Massimo Di Pierro wrote:
>>>
>>> Look ate the source code of urlify:
>>> https://github.com/web2py/web2py/blob/master/gluon/validators.py#L2525
>>>
>>> If you can suggest improvements I will happy to include them. I guess 
>>> the problem is here:
>>>
>>> https://github.com/web2py/web2py/blob/master/gluon/validators.py#L2534
>>>
>>> Massimo
>>>
>>> On Friday, 16 August 2013 07:39:50 UTC-5, lesssugar wrote:

 I'm using the following module to convert my urls:


 http://pydoc.net/Python/redsolutioncms.django-hex-storage/0.1.1/pinyin.urlify/

 I have urlify.py (main function) and maps.py (chars mapping) in my 
 /modules. I test it in one of my views, simply trying to print the 
 urlify-ed value in the console:

 {{from urlify import urlify}}
 {{print urlify(u"łźć ęćm")}}

 I get "aaa-aaa", so basically there's no mapping done and I have no 
 idea 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: making true copy of HTML helpers

2013-08-18 Thread step
Indeed. While I was waiting for replies I realized my question (and 
thinking) was somewhat flawed. What I want to achieve is an SQLFORM.factory 
of two tables, t1 and t2, where t2 is placed after t1.this_field instead of 
after t1.last_field, visually (all s)
t1.field
...
t1.this_field
t2.field
...
t2.last_field
t1.field
...
t1.last_field
submit_record

then I want the user to be able to change to a different t2 (ajax load) by 
selecting an appropriate value of  t1.this_field.
I think it would be simple to output the default combined form - with the 
whole of t2 following the whole of t1 - and then move t2's rows in place 
with jQuery, but I got deep into this experiment of doing all the form 
manipulation using server-side DOM. Maybe I should back out and just do it 
with jQuery, though it's less visually appealing.

On Saturday, August 17, 2013 2:52:27 PM UTC+2, Niphlod wrote:
>
> there's a conceptual problem with your question either you want to 
> save a list of HTML helpers or you need to save a full-blown form. Of 
> course you serializing only the HTML part of the form won't get you 
> form.vars, form.accepts(), etc etc.
> I'm curious though, what and why do you need it?
>
> On Saturday, August 17, 2013 2:33:09 PM UTC+2, step wrote:
>>
>> And in fact it isn't a true copy because after the mapping the so called 
>> trs_true_copy has lost all the SQLFORM specific data, like links to 
>> form.vars, etc. So I don't know of a way to make a true copy, and I'm 
>> asking for one. Thanks.
>>
>> On Saturday, August 17, 2013 2:19:39 PM UTC+2, step wrote:
>>
>>> I discovered one way to make a true copy of some list of HTML helpers. I 
>>> would like to know if there are other more, web2py / pythonic ways to do 
>>> it. So for instance:
>>>
>>> form = SQLFORM.factory()
>>> trs = form.elements('')
>>> trs_true_copy = map(lambda x: TAG(x.xml()),trs)
>>>
>>> which works just fine, though it seems a bit overkill having to 
>>> serialize and deserialize to make a true copy.
>>> TIA
>>>
>>>

-- 

--- 
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: making true copy of HTML helpers

2013-08-18 Thread Niphlod
I think you'd have to rethink the whole process. SQLFORM.factory will work 
only if the "original" fields are the same then the "posted" ones. If 
you're planning to switch tables in the meantime, the form.process() will 
likely NOT work the way you'd expect. 
If you don't want to code your html form by hand (and the relative 
validation logic), I'd simply reload the whole form on that particular 
"first field" and then have something that orders fields the way you like 
BEFORE istantiating the SQLFORM.factory object.
e.g. (not tested)
fields = [db.t1.field1, db.*t2*.field1, db.t1.field2, db.*t2*.field2...]
if "something" in request.get_vars: #or any other thing that "marks" this 
as the request for the "newly ordered" form
fields = [db.t1.field1, db.*t3*.field1, db.t1.field2, db.*t3*.field2...]

form = SQLFORM.factory(*fields)
.



On Sunday, August 18, 2013 2:47:41 PM UTC+2, step wrote:
>
> Indeed. While I was waiting for replies I realized my question (and 
> thinking) was somewhat flawed. What I want to achieve is an SQLFORM.factory 
> of two tables, t1 and t2, where t2 is placed after t1.this_field instead of 
> after t1.last_field, visually (all s)
> t1.field
> ...
> t1.this_field
> t2.field
> ...
> t2.last_field
> t1.field
> ...
> t1.last_field
> submit_record
>
> then I want for the user to be able to change to a different t2 (ajax 
> load) by selecting an appropriate value of  t1.this_field.
> I think it would be simple to output the default combined form - with the 
> whole of t2 following the whole of t1 - and then move t2's rows in place 
> with jQuery, but I got deep into this experiment of doing all the form 
> manipulation using server-side DOM. Maybe I should back out and just do it 
> with jQuery, though it's less visually appealing.
>
>>
>>>

-- 

--- 
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: making true copy of HTML helpers

2013-08-18 Thread step
Brilliantly simple, I should have thought of it. Meanwhile I coded a jQuery 
version and it's simple indeed, but your solution is better. Thanks.

On Sunday, August 18, 2013 3:01:17 PM UTC+2, Niphlod wrote:
>
> I think you'd have to rethink the whole process. SQLFORM.factory will work 
> only if the "original" fields are the same then the "posted" ones. If 
> you're planning to switch tables in the meantime, the form.process() will 
> likely NOT work the way you'd expect. 
> If you don't want to code your html form by hand (and the relative 
> validation logic), I'd simply reload the whole form on that particular 
> "first field" and then have something that orders fields the way you like 
> BEFORE istantiating the SQLFORM.factory object.
> e.g. (not tested)
> fields = [db.t1.field1, db.*t2*.field1, db.t1.field2, db.*t2*.field2...]
> if "something" in request.get_vars: #or any other thing that "marks" this 
> as the request for the "newly ordered" form
> fields = [db.t1.field1, db.*t3*.field1, db.t1.field2, db.*t3*.field2
> ...]
>
> form = SQLFORM.factory(*fields)
> .
>
>
>
> On Sunday, August 18, 2013 2:47:41 PM UTC+2, step wrote:
>>
>> Indeed. While I was waiting for replies I realized my question (and 
>> thinking) was somewhat flawed. What I want to achieve is an SQLFORM.factory 
>> of two tables, t1 and t2, where t2 is placed after t1.this_field instead of 
>> after t1.last_field, visually (all s)
>> t1.field
>> ...
>> t1.this_field
>> t2.field
>> ...
>> t2.last_field
>> t1.field
>> ...
>> t1.last_field
>> submit_record
>>
>> then I want for the user to be able to change to a different t2 (ajax 
>> load) by selecting an appropriate value of  t1.this_field.
>> I think it would be simple to output the default combined form - with the 
>> whole of t2 following the whole of t1 - and then move t2's rows in place 
>> with jQuery, but I got deep into this experiment of doing all the form 
>> manipulation using server-side DOM. Maybe I should back out and just do it 
>> with jQuery, though it's less visually appealing.
>>
>>>


-- 

--- 
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: making true copy of HTML helpers

2013-08-18 Thread step
I'm having trouble finding the right fields= format for SQLFORM.factory.
When fields= is a list of gluon field objects, SQLFORM.factory bails out 
with
 'Field' object has no attribute 'find'

  File "E:\web2py-trunk\web2py\gluon\sqlhtml.py", line 1001, in __init__
if fieldname.find('.') >= 0:
AttributeError: 'Field' object has no attribute 'find'

 
which makes me think it wants take 'tablename.fieldname', and so I did. But 
when fields= is a list of 'tablename.fieldname' form factory bails out with
 'Table' object has no attribute 
'person.id

which makes perfect sense because the attribute name is 'id', so hopelessly 
I tried fields= as a list of 'fieldname' and form factory bails out with
 'Table' object has no attribute 
'table1_field'

when form factory is working on t2, which makes perfect sense again since 
table1_field is not in t2.

On Sunday, August 18, 2013 4:12:45 PM UTC+2, step wrote:
>
> Brilliantly simple, I should have thought of it. Meanwhile I coded a 
> jQuery version and it's simple indeed, but your solution is better. Thanks.
>
> On Sunday, August 18, 2013 3:01:17 PM UTC+2, Niphlod wrote:
>>
>> I think you'd have to rethink the whole process. SQLFORM.factory will 
>> work only if the "original" fields are the same then the "posted" ones. If 
>> you're planning to switch tables in the meantime, the form.process() will 
>> likely NOT work the way you'd expect. 
>> If you don't want to code your html form by hand (and the relative 
>> validation logic), I'd simply reload the whole form on that particular 
>> "first field" and then have something that orders fields the way you like 
>> BEFORE istantiating the SQLFORM.factory object.
>> e.g. (not tested)
>> fields = [db.t1.field1, db.*t2*.field1, db.t1.field2, db.*t2*.field2...]
>> if "something" in request.get_vars: #or any other thing that "marks" 
>> this as the request for the "newly ordered" form
>> fields = [db.t1.field1, db.*t3*.field1, db.t1.field2, db.*t3*.field2
>> ...]
>>
>> form = SQLFORM.factory(*fields)
>> .
>>
>>
>>
>> On Sunday, August 18, 2013 2:47:41 PM UTC+2, step wrote:
>>>
>>> Indeed. While I was waiting for replies I realized my question (and 
>>> thinking) was somewhat flawed. What I want to achieve is an SQLFORM.factory 
>>> of two tables, t1 and t2, where t2 is placed after t1.this_field instead of 
>>> after t1.last_field, visually (all s)
>>> t1.field
>>> ...
>>> t1.this_field
>>> t2.field
>>> ...
>>> t2.last_field
>>> t1.field
>>> ...
>>> t1.last_field
>>> submit_record
>>>
>>> then I want for the user to be able to change to a different t2 (ajax 
>>> load) by selecting an appropriate value of  t1.this_field.
>>> I think it would be simple to output the default combined form - with 
>>> the whole of t2 following the whole of t1 - and then move t2's rows in 
>>> place with jQuery, but I got deep into this experiment of doing all the 
>>> form manipulation using server-side DOM. Maybe I should back out and just 
>>> do it with jQuery, though it's less visually appealing.
>>>

>

-- 

--- 
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: making true copy of HTML helpers

2013-08-18 Thread step
My bad, your answer works perfectly (tested). I hadn't noticed HOW you 
specify fields in the signature, **fields* instead of fields=

On Sunday, August 18, 2013 5:33:46 PM UTC+2, step wrote:
>
> I'm having trouble finding the right fields= format for SQLFORM.factory.
> When fields= is a list of gluon field objects, SQLFORM.factory bails out 
> with
>  'Field' object has no attribute 'find'
>
>   File "E:\web2py-trunk\web2py\gluon\sqlhtml.py", line 1001, in __init__
> if fieldname.find('.') >= 0:
> AttributeError: 'Field' object has no attribute 'find'
>
>  
> which makes me think it wants fields= as a list of 'tablename.fieldname'. 
> But when fields= is a list of 'tablename.fieldname' form factory bails out 
> with
>  'Table' object has no attribute '
> person.id
>
> which makes perfect sense because the attribute name is 'id', so 
> hopelessly I try fields= as a list of 'fieldname' and form factory bails 
> out with
>  'Table' object has no attribute 
> 'table1_field'
>
> when form factory is working on t2, which makes perfect sense again since 
> table1_field is not in t2.
>
> On Sunday, August 18, 2013 4:12:45 PM UTC+2, step wrote:
>>
>> Brilliantly simple, I should have thought of it. Meanwhile I coded a 
>> jQuery version and it's simple indeed, but your solution is better. Thanks.
>>
>> On Sunday, August 18, 2013 3:01:17 PM UTC+2, Niphlod wrote:
>>>
>>> I think you'd have to rethink the whole process. SQLFORM.factory will 
>>> work only if the "original" fields are the same then the "posted" ones. If 
>>> you're planning to switch tables in the meantime, the form.process() will 
>>> likely NOT work the way you'd expect. 
>>> If you don't want to code your html form by hand (and the relative 
>>> validation logic), I'd simply reload the whole form on that particular 
>>> "first field" and then have something that orders fields the way you like 
>>> BEFORE istantiating the SQLFORM.factory object.
>>> e.g. (not tested)
>>> fields = [db.t1.field1, db.*t2*.field1, db.t1.field2, db.*t2*.field2...]
>>> if "something" in request.get_vars: #or any other thing that "marks" 
>>> this as the request for the "newly ordered" form
>>> fields = [db.t1.field1, db.*t3*.field1, db.t1.field2, db.*t3*.field2
>>> ...]
>>>
>>> form = SQLFORM.factory(*fields)
>>> .
>>>
>>>
>>>
>>> On Sunday, August 18, 2013 2:47:41 PM UTC+2, step wrote:

 Indeed. While I was waiting for replies I realized my question (and 
 thinking) was somewhat flawed. What I want to achieve is an 
 SQLFORM.factory 
 of two tables, t1 and t2, where t2 is placed after t1.this_field instead 
 of 
 after t1.last_field, visually (all s)
 t1.field
 ...
 t1.this_field
 t2.field
 ...
 t2.last_field
 t1.field
 ...
 t1.last_field
 submit_record

 then I want for the user to be able to change to a different t2 (ajax 
 load) by selecting an appropriate value of  t1.this_field.
 I think it would be simple to output the default combined form - with 
 the whole of t2 following the whole of t1 - and then move t2's rows in 
 place with jQuery, but I got deep into this experiment of doing all the 
 form manipulation using server-side DOM. Maybe I should back out and just 
 do it with jQuery, though it's less visually appealing.

>
>>

-- 

--- 
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: db.mytable.myfield.contains() gives an error Query Not Supported: parser stack overflow

2013-08-18 Thread dave
you can pass a list, 
http://www.web2py.com/book/default/chapter/06#like,-regexp,-startswith,-contains,-upper,-lower
It works fine for a small list, but when you get past a certain number 
maybe a 100 or a 1000, it gives an error, same thing with belongs. I think 
the nesting with the parenthesis becomes very high, and the stack 
overflows, I suspect it is an sqlite problem? 
To explain what it does, the query is part of a larger dynamic query,

 

>
> x = something
> y = something
> z = something
> queries=[] # an empty query to build a list upon
>
> queries.append(db.mytable.myfield_1.contains(x))
> queries.append(db.mytable.myfield_2.contains(y))
> queries.append(db.mytable.myfield_3.contains(z))
> .
> .
> queries.append(db.mytable.myfield_10.contains(a))
> query = reduce(lambda a,b:(a&b),queries)
> grid = SQLFORM.grid(query, ...)
> return (grid=grid)


On Sunday, August 18, 2013 1:06:39 AM UTC-7, Massimo Di Pierro wrote:
>
> I think by this:
>
> x = ['a', 'b', 'c', ...]
> queries.append(db.mytable.myfield.contains(x))
>
> you mean:
>
> x = ['a', 'b', 'c', ...]
> queries.append(db.mytable.myfield.belongs(x))
>
> You cannot pass a list to contains. That may part of the problem.
> there may be other problems. Can you show more code or explain what the 
> query is supposed to do?
>
> Massimo
>
>
> On Saturday, 17 August 2013 21:11:52 UTC-5, dave wrote:
>>
>> I guess nobody encountered this issue before?
>>
>> On Thursday, August 15, 2013 11:59:31 AM UTC-7, dave wrote:
>>>
>>> .
>>> .
>>> .
>>> x = ['a', 'b', 'c', ...]
>>> queries.append(db.mytable.myfield.contains(x))
>>> query = reduce(lambda a,b:(a&b),queries)
>>> grid = SQLFORM.grid(query, ...)
>>>
>>> return (grid=grid)
>>>
>>> gives an error of "Query Not Supported: parser stack overflow", if the 
>>> list x has too many values, like around 100 or a 1000, I suspect its an 
>>> sqlite limitation? can anyone suggest another succinct way of passing a 
>>> list to a contain like operator or method. 
>>>
>>

-- 

--- 
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: making true copy of HTML helpers

2013-08-18 Thread Niphlod
Indeed...SQLFORM.factory() doesn't take any named arguments:  def 
factory(*fields, **attributes):

On Sunday, August 18, 2013 5:41:32 PM UTC+2, step wrote:
>
> My bad, your answer works perfectly (tested). I hadn't noticed HOW you 
> specify fields in the signature, **fields* instead of fields=
>
> On Sunday, August 18, 2013 5:33:46 PM UTC+2, step wrote:
>>
>> I'm having trouble finding the right fields= format for SQLFORM.factory.
>> When fields= is a list of gluon field objects, SQLFORM.factory bails out 
>> with
>>  'Field' object has no attribute 'find'
>>
>>   File "E:\web2py-trunk\web2py\gluon\sqlhtml.py", line 1001, in __init__
>> if fieldname.find('.') >= 0:
>> AttributeError: 'Field' object has no attribute 'find'
>>
>>  
>> which makes me think it wants fields= as a list of 'tablename.fieldname'. 
>> But when fields= is a list of 'tablename.fieldname' form factory bails out 
>> with
>>  'Table' object has no attribute '
>> person.id
>>
>> which makes perfect sense because the attribute name is 'id', so 
>> hopelessly I try fields= as a list of 'fieldname' and form factory bails 
>> out with
>>  'Table' object has no attribute 
>> 'table1_field'
>>
>> when form factory is working on t2, which makes perfect sense again since 
>> table1_field is not in t2.
>>
>> On Sunday, August 18, 2013 4:12:45 PM UTC+2, step wrote:
>>>
>>> Brilliantly simple, I should have thought of it. Meanwhile I coded a 
>>> jQuery version and it's simple indeed, but your solution is better. Thanks.
>>>
>>> On Sunday, August 18, 2013 3:01:17 PM UTC+2, Niphlod wrote:

 I think you'd have to rethink the whole process. SQLFORM.factory will 
 work only if the "original" fields are the same then the "posted" ones. If 
 you're planning to switch tables in the meantime, the form.process() will 
 likely NOT work the way you'd expect. 
 If you don't want to code your html form by hand (and the relative 
 validation logic), I'd simply reload the whole form on that particular 
 "first field" and then have something that orders fields the way you like 
 BEFORE istantiating the SQLFORM.factory object.
 e.g. (not tested)
 fields = [db.t1.field1, db.*t2*.field1, db.t1.field2, db.*t2*.field2
 ...]
 if "something" in request.get_vars: #or any other thing that "marks" 
 this as the request for the "newly ordered" form
 fields = [db.t1.field1, db.*t3*.field1, db.t1.field2, db.*t3*.
 field2...]

 form = SQLFORM.factory(*fields)
 .



 On Sunday, August 18, 2013 2:47:41 PM UTC+2, step wrote:
>
> Indeed. While I was waiting for replies I realized my question (and 
> thinking) was somewhat flawed. What I want to achieve is an 
> SQLFORM.factory 
> of two tables, t1 and t2, where t2 is placed after t1.this_field instead 
> of 
> after t1.last_field, visually (all s)
> t1.field
> ...
> t1.this_field
> t2.field
> ...
> t2.last_field
> t1.field
> ...
> t1.last_field
> submit_record
>
> then I want for the user to be able to change to a different t2 (ajax 
> load) by selecting an appropriate value of  t1.this_field.
> I think it would be simple to output the default combined form - with 
> the whole of t2 following the whole of t1 - and then move t2's rows in 
> place with jQuery, but I got deep into this experiment of doing all the 
> form manipulation using server-side DOM. Maybe I should back out and just 
> do it with jQuery, though it's less visually appealing.
>
>>
>>>

-- 

--- 
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 identify the active .table files

2013-08-18 Thread at
Thank you for detailed explaination. 

Sorry I couldn't understand that how can we live with a blank databases 
folder?

Suppose server1 is active and it has filled databases folder, and server2 
is passive with empty databases folder. Both are pointing to same database 
which is on server3. My understanding is when server1 will become passive 
and server2 active, application (running on server2) will crash because it 
will try to create tables in the database and these tables are already 
exist? Please correct me.

Thanks & Regards

On Sunday, 18 August 2013 14:35:53 UTC+5, Niphlod wrote:

> Once the migration has been done and you set migrate=False, you can 
> totally live with an empty databases/ folder because .table files are not 
> necessary.
> My point being: depending on your architecture, you may decide to have 
> migration happening only on server1 (where you keep your databases/ folder 
> "filled") and have server2 with migrate=False with no .table files 
> whatsoever.
>

-- 

--- 
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: How to identify the active .table files

2013-08-18 Thread Jonathan Lundell
On 18 Aug 2013, at 10:48 AM, at  wrote:
> Thank you for detailed explaination. 
> 
> Sorry I couldn't understand that how can we live with a blank databases 
> folder?
> 
> Suppose server1 is active and it has filled databases folder, and server2 is 
> passive with empty databases folder. Both are pointing to same database which 
> is on server3. My understanding is when server1 will become passive and 
> server2 active, application (running on server2) will crash because it will 
> try to create tables in the database and these tables are already exist? 
> Please correct me.

The table files are needed only for migration. By "active", Niphlod means the 
server responsible for doing migrations; the "passive" server never performs 
migrations, so it never needs table files. Notice that, apart from migrations, 
the servers "know" about the database schema from the define_table calls, not 
from the table files.

> 
> Thanks & Regards
> 
> On Sunday, 18 August 2013 14:35:53 UTC+5, Niphlod wrote:
> Once the migration has been done and you set migrate=False, you can totally 
> live with an empty databases/ folder because .table files are not necessary.
> My point being: depending on your architecture, you may decide to have 
> migration happening only on server1 (where you keep your databases/ folder 
> "filled") and have server2 with migrate=False with no .table files whatsoever.
> 
> 


-- 

--- 
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: How to identify the active .table files

2013-08-18 Thread at

IC, I was not aware of that. I thought application can't be run without 
having a filled databases folder. So with empty folder, do we have to 
explicitly define *migrate=False*? and by default migrate=True?

Thanks,

On Sunday, 18 August 2013 22:54:45 UTC+5, Jonathan Lundell wrote:
>
> On 18 Aug 2013, at 10:48 AM, at > wrote: 
> > Thank you for detailed explaination. 
> > 
> > Sorry I couldn't understand that how can we live with a blank databases 
> folder? 
> > 
> > Suppose server1 is active and it has filled databases folder, and 
> server2 is passive with empty databases folder. Both are pointing to same 
> database which is on server3. My understanding is when server1 will become 
> passive and server2 active, application (running on server2) will crash 
> because it will try to create tables in the database and these tables are 
> already exist? Please correct me. 
>
> The table files are needed only for migration. By "active", Niphlod means 
> the server responsible for doing migrations; the "passive" server never 
> performs migrations, so it never needs table files. Notice that, apart from 
> migrations, the servers "know" about the database schema from the 
> define_table calls, not from the table files. 
>
> > 
> > Thanks & Regards 
> > 
> > On Sunday, 18 August 2013 14:35:53 UTC+5, Niphlod wrote: 
> > Once the migration has been done and you set migrate=False, you can 
> totally live with an empty databases/ folder because .table files are not 
> necessary. 
> > My point being: depending on your architecture, you may decide to have 
> migration happening only on server1 (where you keep your databases/ folder 
> "filled") and have server2 with migrate=False with no .table files 
> whatsoever. 
> > 
> > 
>
>
>

-- 

--- 
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: How to identify the active .table files

2013-08-18 Thread Anthony
On Sunday, August 18, 2013 2:03:47 PM UTC-4, at wrote:

>
> IC, I was not aware of that. I thought application can't be run without 
> having a filled databases folder. So with empty folder, do we have to 
> explicitly define *migrate=False*? and by default migrate=True?
>

Yes, by default, migrate=True. To turn off migrations for an entire DAL 
connection, do:

db = DAL(..., migrate_enabled=False)

Anthony 

-- 

--- 
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] {{=customform.custom.widget.delete_record}} is None

2013-08-18 Thread Annet
I have a custom form in which the check to delete checkbox isn't being 
displayed:

{{=customform.custom.widget.delete_record}}

What is the correct syntax to get the box displayed?


Kind regards,

Annet


{{if customform:}}
  

  

  {{=customform.custom.widget.contents}}
 
   
  

  {{=customform.custom.widget.delete_record}}
 
   
  

  {{=customform.custom.submit}}
  Cancel
  {{=customform.custom.end}}
 
   

{{pass}}

-- 

--- 
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] primarykey vs is_not_in_db

2013-08-18 Thread Antonis Konstantinos Tzorvas
http://paste.kde.org/p6938ac83/55437137/

trying to use primarykey=['station_id', 'source'] in db.stations_sources i 
was always getting the 'no _id error' when trying to apply a "proper" 
db.data.source.requires=IS_IN_DB(db, 'stations_soruces.station_id', 
'stations_sources.source') 

is there any way to achieve this by using primarykey=['station_id', 
'source'] in db.stations_sources instead substituting line 24?
or is it better to use it as is right now?

-- 

--- 
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: urlify - no char mapping

2013-08-18 Thread villas
FWIW this mapping helped me once in the past...

https://github.com/GoodCloud/django-rewrite/blob/master/libs/slughifi.py

-- 

--- 
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: sharing my d3.js experiments with web2py community

2013-08-18 Thread PRACHI VAKHARIA

Thank you for sharing this, dear Margaret.
After going through it, I will write to you if I have any questions or 
doubts.
— Prachi


-- 

--- 
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: Send and save as draft email forms

2013-08-18 Thread PRACHI VAKHARIA


*On Sunday, August 18, 2013 4:01:26 AM UTC-4, Massimo Di Pierro wrote:*
>
> *Why should web2py include mail storage? It looks more like an app to me 
> than a core feature.*
>



Dear Massimo,
That is a great question, and let me try to make a case for that.
Currently w2p provides DAL abstraction to read IMAP and send emails using 
SMTP, but *(as per what I understood from Alan Etkin — I may have 
misunderstood as well)* it does not allow saving of Email as drafts.
If we imagine IMAP to be a DB for emails, then w2p DAL has the ability to 
read the IMAP data (emails) but not write, save or append IMAP data 
(drafts). That is like the ability to read data from an SQL-DB but not 
having the ability to write to it. And that is a little bit limiting. Of 
course, there have to be work-arounds for all that. But when there is read 
and send, why not have save (write-append) too?
Please think about it. Composing of an email message can go in two main 
directions:


   1. Send » SMTP — this has been implemented
  2. Save as Draft » IMAP — this option appears to be missing.
   
Send from Drafts » IMAP to SMTP — this can be done currently, but can the 
draft itself be created?

 

If I have not understood anything properly, please do enlighten me. And if 
you think that there is any merit to my case above, please consider it 
favorably.
Thank you.

Regards,
PRACHI




.

-- 

--- 
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] "Automatic" validators being set for tables

2013-08-18 Thread Joe Barnhart
I'm having problems with some automatic validators being set on my tables. 
 I have fields which are optional, they are NOT set as "notnull=True" and I 
did not provide anyvalidator -- but I DID set a length for the field, as is 
good practice for most databases.

It appears those fields are being set with an automatic validator for field 
length, and as a consequence they are behaving as though they are 
"required" fields.  I get an error if the field is left empty during the 
validation phase of my form.  I can null out this automatic validation by 
setting requires=[] on each field, but I have something like 50 fields in 
this table.  They are not all string fields, either, so a blanket 
requires=[] would probably screw up some of the fields.

Is there a way to make the automatic validators for length handle 
IS_EMPTY_OR correctly for fields that may be empty?

-- Joe

-- 

--- 
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: MOD_WSGI and web2py doesn't allow url below root

2013-08-18 Thread jonten
Thank you for the answer and the detailed explanation :)

On Sunday, August 18, 2013 10:04:23 AM UTC+2, Massimo Di Pierro wrote:
>
> P.S. Also I would make a distinction on whether the mapping is done to 
> remove a BASE (use apache) for aesthetic reasons (also use Apache) or for 
> functional reasons (use routes.py).
>
> By functional reasons I man that the app would break without the mapping. 
> If the app would break than the mapping belongs to the web2py level 
> (routes.py or app level routes.py).
>
> On Sunday, 18 August 2013 03:02:47 UTC-5, Massimo Di Pierro wrote:
>>
>> I would use Apache. Mostly because it is a little faster. 
>>
>> On Saturday, 17 August 2013 16:48:38 UTC-5, jonten wrote:
>>>
>>> Hi Massimo,
>>>
>>> I am just curious to know if it is better to modify BASE in routes.py 
>>> than using the config below in Apache vhost config instead of 
>>> WSGIScriptAlias? Or if it is equvivalent:
>>>
>>> WSGIScriptAliasMatch ^/myapp.* /var/www/web2py/wsgihandler.py
>>>
>>> Best regards,
>>> //Jon
>>>
>>>

-- 

--- 
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] urlify - no char mapping

2013-08-18 Thread Jonathan Lundell
Another possibility (I haven't tried it): 
https://pypi.python.org/pypi/Unidecode/0.04.1

-- 

--- 
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: {{=customform.custom.widget.delete_record}} is None

2013-08-18 Thread Niphlod
according to docs
http://web2py.com/books/default/chapter/29/07/forms-and-validators#Custom-forms
it's form.custom.delete


On Sunday, August 18, 2013 10:07:32 PM UTC+2, Annet wrote:
>
> I have a custom form in which the check to delete checkbox isn't being 
> displayed:
>
> {{=customform.custom.widget.delete_record}}
>
> What is the correct syntax to get the box displayed?
>
>
> Kind regards,
>
> Annet
>
>
> {{if customform:}}
>class="form-inline">
> 
>   
> 
>   {{=customform.custom.widget.contents}}
>  
>
>   
> 
>   {{=customform.custom.widget.delete_record}}
>  
>
>   
> 
>   {{=customform.custom.submit}}
>   Cancel
>   {{=customform.custom.end}}
>  
>
> 
> {{pass}}
>

-- 

--- 
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] urlify - no char mapping

2013-08-18 Thread Niphlod
i like django-urlify and slughify module structure better ... unicodedecode 
is yet another module that fiddles heavily with imports (it's 118 files) 
and I don't see it included in contrib if we're going to include its logic 
in IS_SLUG()...


On Sunday, August 18, 2013 10:56:41 PM UTC+2, Jonathan Lundell wrote:
>
> Another possibility (I haven't tried it): 
> https://pypi.python.org/pypi/Unidecode/0.04.1

-- 

--- 
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] Two tables, one form -- with a twist

2013-08-18 Thread Joe Barnhart
My form processing skills have been pushed beyond my understanding of 
web2py.  Maybe I'm going about this the wrong way and someone with more 
chops can steer me along...

I have two tables.  Table RO is a table of sacrosanct data.  It can be used 
for processing, but must never be changed.  Table W is a working table.  It 
is a complete superset of Table RO -- it all all of RO's fields plus a few 
more.  The idea is that users will pick a record from Table RO, edit it, 
and store the results in Table W.  If the user has already edited the 
record once, then the source for future edits should be Table W and Table 
RO is no longer used.

So in pseudo code, here is my approach:


 if work_table_id:
form = SQLFORM(db.work_table, work_table_id, ...etc...)

 elif ro_table_id:
fields = db.ro_table(ro_table_id)
del fields.id
form = SQLFORM(db.work_table, ...etc...)
form.vars.update(**fields)

 form.vars.this = my_preset_for_this
 form.vars.that = my_preset_for_that
 ...

 if form.validate():
formvars = dict(request.vars) # request.post.vars? form.vars?
formvars.my_calculated_value1 = calculation1
formvars.my_calculated_value2 = calculation2
...

id = db.work_table.insert(**formvars)

 elif form.errors:
response.flash = 'my error message here'


I'm having a hell of a time.  I get different form names depending on which 
path is taken.  I get conflicts between formkey and formname.  I get "value 
is empty" validation failures on fields I'm not using in the form (I 
compute a subset of the fields since the information is redundant in some 
way).  Should I just punt SQLFORM and do it all manually?

-- Joe

-- 

--- 
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] urlify - no char mapping

2013-08-18 Thread Jonathan Lundell
On 18 Aug 2013, at 2:22 PM, Niphlod  wrote:
> i like django-urlify and slughify module structure better ... unicodedecode 
> is yet another module that fiddles heavily with imports (it's 118 files) and 
> I don't see it included in contrib if we're going to include its logic in 
> IS_SLUG()...

The fiddling is pretty straightforward, just lazy imports of blocks of 
characters. Which makes sense. OTOH, its intention is slightly different from 
other slugifiers:

from unidecode import unidecode:
unidecode(u"北亰")
"Bei Jing "

...it *is* sorta cool.

> 
> 
> On Sunday, August 18, 2013 10:56:41 PM UTC+2, Jonathan Lundell wrote:
> Another possibility (I haven't tried it): 
> https://pypi.python.org/pypi/Unidecode/0.04.1
> 
> 


-- 

--- 
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: Two databases with an auth in each

2013-08-18 Thread dave
I just bumped into this situation also, my case is students and employers, 
when I register employers I want to have 
"auth.settings.registration_requires_approval 
= True" and a different profile, but students can just register without 
requiring approval from admin

On Saturday, April 13, 2013 11:24:44 AM UTC-7, Anthony wrote:
>
> Interesting use case -- I think cases like that have come up before (i.e., 
> where different roles need different types of profiles). May be worth 
> supporting somehow, but not sure about the best approach.
>
> For now, you might consider putting all the profile fields in the 
> auth_user table, and just selectively make some readable/writable depending 
> on which registration/profile action is being used. Alternatively, you 
> could create separate tables that are simply linked to the auth_user table. 
> Either approach will require creating somewhat customized register and 
> profile actions, but that shouldn't be too difficult, and other than that, 
> I'm not sure there's much else to worry about.
>
> If you want to use separate applications, they can share a database, 
> though it's trickier to share model definitions (you could put them in 
> modules and import, or use the auto-import method) -- for more, see 
> http://web2py.com/books/default/chapter/29/06#Using-DAL-without-define-tables.
>  
> I'm not sure I would create separate apps just for the sake of this Auth 
> issue, but if it makes sense otherwise to have separate apps, they can 
> share databases.
>
> Anthony
>
> On Saturday, April 13, 2013 1:53:47 PM UTC-4, David Ripplinger wrote:
>>
>> Okay, that makes sense. It might not be worth modifying web2py for this 
>> behavior when there may be a cleaner way of doing it. I had considered 
>> using the inherent roles and permissions, but there are several reasons why 
>> this would be awkward for my particular case. The main reason is that I 
>> overload the auth_user table with lots of data about a particular user. The 
>> fields I include are completely different for a regular user as opposed to 
>> a partner. I don't want a regular user, upon registration, to automatically 
>> have partner features or vice versa. In the uncommon case that someone 
>> wants both, I would want them to sign up for the two kinds of accounts 
>> separately. I also, in that case, want the ability for there to be a user 
>> account and a partner account both with the same email address, but I don't 
>> want two user (or partner) accounts to have the same email.
>>
>> Ideally, I would put the partners portal under a different subdomain so 
>> that the two aspects of the app are very much separated. For this reason, 
>> I'm really leaning toward running two web2py apps and giving both access to 
>> each other's databases and possibly expose a couple functions for them to 
>> communicate. But I don't know if web2py is designed to do this either.
>>
>> On Saturday, April 13, 2013 1:18:00 PM UTC-4, Anthony wrote:
>>>
>>> I think the problem is that Auth creates an object called "auth" in the 
>>> session, and the name of this session object is fixed. So, once someone 
>>> logs in with one of your Auth instances, the other instance will pull the 
>>> "auth" object from the session and think they are logged in with that 
>>> instance as well. I suppose we could add the ability to customize the name 
>>> of the session object to avoid this problem (though not sure there wouldn't 
>>> be other problems with this approach). Anyway, this is exactly what the 
>>> roles and permissions aspects of the Auth system are designed to address. 
>>> Why not just create "user" and "partner" roles and use 
>>> @auth.requires_membership(...)?
>>>
>>> Anthony
>>>
>>> On Saturday, April 13, 2013 12:32:36 PM UTC-4, David Ripplinger wrote:

 In my project, it makes a lot of sense to have two separate databases: 
 one for the users of the app and another for partners who pay to advertise 
 to those users. The data they manipulate are completely different sets. I 
 have created an auth object (named auth) for the users database (called 
 db) 
 and another auth object (named authp) for the partners database (called 
 dbp). I want all users stuff to be under the url myapp/default and all 
 partners stuff to be under the url myapp/partners.

 The problem is that the app is mixing the two types of user accounts 
 together in two ways:

1. If I create a user account and a partner account with the same 
credentials, then signing into one allows access to the pages 
 restricted by 
the other (and yes, I changed the decorators to @authp instead of @auth 
 for 
the partners pages). This is especially bad without email verification 
(which I have not implemented yet), since someone can register as a 
 partner 
under the same email as an already existing regular user but with a 
different password. This woul

[web2py] Re: Two databases with an auth in each

2013-08-18 Thread dave
I just bumped into the same situation, can you tell me which route you 
took? did you decide to have two applications or the other way?

On Saturday, April 13, 2013 10:53:47 AM UTC-7, David Ripplinger wrote:
>
> Okay, that makes sense. It might not be worth modifying web2py for this 
> behavior when there may be a cleaner way of doing it. I had considered 
> using the inherent roles and permissions, but there are several reasons why 
> this would be awkward for my particular case. The main reason is that I 
> overload the auth_user table with lots of data about a particular user. The 
> fields I include are completely different for a regular user as opposed to 
> a partner. I don't want a regular user, upon registration, to automatically 
> have partner features or vice versa. In the uncommon case that someone 
> wants both, I would want them to sign up for the two kinds of accounts 
> separately. I also, in that case, want the ability for there to be a user 
> account and a partner account both with the same email address, but I don't 
> want two user (or partner) accounts to have the same email.
>
> Ideally, I would put the partners portal under a different subdomain so 
> that the two aspects of the app are very much separated. For this reason, 
> I'm really leaning toward running two web2py apps and giving both access to 
> each other's databases and possibly expose a couple functions for them to 
> communicate. But I don't know if web2py is designed to do this either.
>
> On Saturday, April 13, 2013 1:18:00 PM UTC-4, Anthony wrote:
>>
>> I think the problem is that Auth creates an object called "auth" in the 
>> session, and the name of this session object is fixed. So, once someone 
>> logs in with one of your Auth instances, the other instance will pull the 
>> "auth" object from the session and think they are logged in with that 
>> instance as well. I suppose we could add the ability to customize the name 
>> of the session object to avoid this problem (though not sure there wouldn't 
>> be other problems with this approach). Anyway, this is exactly what the 
>> roles and permissions aspects of the Auth system are designed to address. 
>> Why not just create "user" and "partner" roles and use 
>> @auth.requires_membership(...)?
>>
>> Anthony
>>
>> On Saturday, April 13, 2013 12:32:36 PM UTC-4, David Ripplinger wrote:
>>>
>>> In my project, it makes a lot of sense to have two separate databases: 
>>> one for the users of the app and another for partners who pay to advertise 
>>> to those users. The data they manipulate are completely different sets. I 
>>> have created an auth object (named auth) for the users database (called db) 
>>> and another auth object (named authp) for the partners database (called 
>>> dbp). I want all users stuff to be under the url myapp/default and all 
>>> partners stuff to be under the url myapp/partners.
>>>
>>> The problem is that the app is mixing the two types of user accounts 
>>> together in two ways:
>>>
>>>1. If I create a user account and a partner account with the same 
>>>credentials, then signing into one allows access to the pages restricted 
>>> by 
>>>the other (and yes, I changed the decorators to @authp instead of @auth 
>>> for 
>>>the partners pages). This is especially bad without email verification 
>>>(which I have not implemented yet), since someone can register as a 
>>> partner 
>>>under the same email as an already existing regular user but with a 
>>>different password. This would allow someone else to hack the user's 
>>>account.
>>>2. All the redirects are messed up. Usually, after registering or 
>>>signing in, unless the URL specifies a different redirect explicitly, 
>>>things always redirect back to the user account and never to the partner 
>>>account page.
>>>
>>> How should I be handling this properly? Any tips for having two very 
>>> different types of users are much appreciated.
>>>
>>> An alternative I would be happy with is actually making two separate 
>>> apps, but I'm not sure how to exchange some database information between 
>>> them. Can one app access the database of another app? Does it matter if I'm 
>>> currently using sqlite?
>>>
>>

-- 

--- 
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] diffrence between web2py and django framework...

2013-08-18 Thread António Ramos
Web2py is good for osteoporosis ,you type a lot less!
;)

No dia Sábado, 17 de Agosto de 2013, Carlos
correiacar...@memoriapersistente.pt escreveu:

> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
>
> Em 16-08-2013 19:09, Udeme Samuel escreveu:
> > hello developers please i am new  to web2py and django but i want to
> know what
> > is the diffrence between the two of them and which of the framework is
> more
> > productive...
> >
> > --
> >
> > ---
> > 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.
>
> If you had googled first for "Web2py vs django"
> (https://www.google.com/search?channel=fs&q=web2py+vs+django), you might
> have
> noticed the first result:
>
> http://stackoverflow.com/questions/4352428/django-vs-web2py-for-a-beginner-developer
> ("Django vs web2py for a beginner developer").
>
> Have fun,
> - --
> Com os melhores cumprimentos,
>
> Carlos Correia
> =
> MEMÓRIA PERSISTENTE
> Tel.: 219 291 591 - GSM:  917 157 146 / 967 511 762
> e-mail: ge...@memoriapersistente.pt  - URL:
> http://www.memoriapersistente.pt
> Jabber: m...@jabber.org 
> GnuPG: wwwkeys.eu.pgp.net
> URL Suporte: https://t5.m16e.com/gps
> -BEGIN PGP SIGNATURE-
> Version: GnuPG v1.4.12 (GNU/Linux)
> Comment: Using GnuPG with undefined - http://www.enigmail.net/
>
> iEYEARECAAYFAlIP5bMACgkQ90uzwjA1SJUi2QCdG3xJinTBU0Cpf3NbtlV4/tDf
> ybMAnAgzwE+Jvm9TYxeUq+5hHPk6H5ES
> =omLS
> -END PGP SIGNATURE-
>
> --
>
> ---
> 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] plugin_clientapi

2013-08-18 Thread Simon Ashley

Alan, you you have a simple example app, that just goes through the basics.
Have looking at it and trying to learn it but have come up against 
configuration issues/ errors.
It would help me out if I could study a simple app, that works, to see 
where I've gone wrong.
TIA

-- 

--- 
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] urlify - no char mapping

2013-08-18 Thread Niphlod


On Monday, August 19, 2013 12:14:48 AM UTC+2, Jonathan Lundell wrote:
>
> On 18 Aug 2013, at 2:22 PM, Niphlod > 
> wrote:
>
> i like django-urlify and slughify module structure better ... 
> unicodedecode is yet another module that fiddles heavily with imports (it's 
> 118 files) and I don't see it included in contrib if we're going to include 
> its logic in IS_SLUG()...
>
>
> The fiddling is pretty straightforward, just lazy imports of blocks of 
> characters. Which makes sense. OTOH, its intention is slightly different 
> from other slugifiers:
>
> from unidecode import unidecode:
> unidecode(u"北亰")
> "Bei Jing "
>
> ...it *is* sorta cool.
>
>
totally agree, but the module including the mappings as dict in one file as 
in hex_storage I think lands the same result, and it's only one file vs 118 
to ship in contrib  

-- 

--- 
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: Two tables, one form -- with a twist

2013-08-18 Thread Niphlod
Given that you are pretty down the line of deciding what table needs to be 
"touched", you should just write a wrapper that either inserts a record on 
work_table and let the users edit it or that it copies the values from the 
ro_table to the work_table as defaults, and then prepare a "prefilled" form 
with fields from the work_table.

pseudo_code
if user_selected_ro:
 values = db(db.ro_table.id == user_selected_ro).select().first()
 .
 for f in db.work_table.fields:
 db.work_table[f].default = values[f]
form = SQLFORM(db.work_table)
.

Given that some of the fields are calculated, you may want to use 
SQLFORM.factory as well, because you'd likely want to manage the inserted 
data a little bit before the insertion on the work_table.

-- 

--- 
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] urlify - no char mapping

2013-08-18 Thread Jonathan Lundell
On 18 Aug 2013, at 5:56 PM, Niphlod  wrote:
> On Monday, August 19, 2013 12:14:48 AM UTC+2, Jonathan Lundell wrote:
> On 18 Aug 2013, at 2:22 PM, Niphlod  wrote:
>> i like django-urlify and slughify module structure better ... unicodedecode 
>> is yet another module that fiddles heavily with imports (it's 118 files) and 
>> I don't see it included in contrib if we're going to include its logic in 
>> IS_SLUG()...
> 
> The fiddling is pretty straightforward, just lazy imports of blocks of 
> characters. Which makes sense. OTOH, its intention is slightly different from 
> other slugifiers:
> 
> from unidecode import unidecode:
> unidecode(u"北亰")
> "Bei Jing "
> 
> ...it *is* sorta cool.
> 
> 
> totally agree, but the module including the mappings as dict in one file as 
> in hex_storage I think lands the same result, and it's only one file vs 118 
> to ship in contrib  
> 
> 

There's always zipimport...

-- 

--- 
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: primarykey vs is_not_in_db

2013-08-18 Thread Massimo Di Pierro
Please open a ticket about this.

On Sunday, 18 August 2013 15:11:45 UTC-5, Antonis Konstantinos Tzorvas 
wrote:
>
> http://paste.kde.org/p6938ac83/55437137/
>
> trying to use primarykey=['station_id', 'source'] in db.stations_sources i 
> was always getting the 'no _id error' when trying to apply a "proper" 
> db.data.source.requires=IS_IN_DB(db, 'stations_soruces.station_id', 
> 'stations_sources.source') 
>
> is there any way to achieve this by using primarykey=['station_id', 
> 'source'] in db.stations_sources instead substituting line 24?
> or is it better to use it as is right now?
>

-- 

--- 
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: Send and save as draft email forms

2013-08-18 Thread Massimo Di Pierro
I am convinced. Thanks Prachi. I believe Alan is on the case.

On Sunday, 18 August 2013 15:32:13 UTC-5, PRACHI VAKHARIA wrote:
>
>
>
> *On Sunday, August 18, 2013 4:01:26 AM UTC-4, Massimo Di Pierro wrote:*
>>
>> *Why should web2py include mail storage? It looks more like an app to me 
>> than a core feature.*
>>
>
>
>
> Dear Massimo,
> That is a great question, and let me try to make a case for that.
> Currently w2p provides DAL abstraction to read IMAP and send emails using 
> SMTP, but *(as per what I understood from Alan Etkin — I may have 
> misunderstood as well)* it does not allow saving of Email as drafts.
> If we imagine IMAP to be a DB for emails, then w2p DAL has the ability to 
> read the IMAP data (emails) but not write, save or append IMAP data 
> (drafts). That is like the ability to read data from an SQL-DB but not 
> having the ability to write to it. And that is a little bit limiting. Of 
> course, there have to be work-arounds for all that. But when there is read 
> and send, why not have save (write-append) too?
> Please think about it. Composing of an email message can go in two main 
> directions:
>
>
>1. Send » SMTP — this has been implemented
>   2. Save as Draft » IMAP — this option appears to be missing.
>
> Send from Drafts » IMAP to SMTP — this can be done currently, but can the 
> draft itself be created?
>
>  
>
> If I have not understood anything properly, please do enlighten me. And if 
> you think that there is any merit to my case above, please consider it 
> favorably.
> Thank you.
>
> Regards,
> PRACHI
>
>
>
>
> .
>

-- 

--- 
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: "Automatic" validators being set for tables

2013-08-18 Thread Massimo Di Pierro
Can you post some code so we can reproduce it?  This should not be 
happening. In fact the first line of the IS_LENGTH.__call__ validators 
check for value == None and assumes length == 0

On Sunday, 18 August 2013 15:42:31 UTC-5, Joe Barnhart wrote:
>
> I'm having problems with some automatic validators being set on my tables. 
>  I have fields which are optional, they are NOT set as "notnull=True" and I 
> did not provide anyvalidator -- but I DID set a length for the field, as is 
> good practice for most databases.
>
> It appears those fields are being set with an automatic validator for 
> field length, and as a consequence they are behaving as though they are 
> "required" fields.  I get an error if the field is left empty during the 
> validation phase of my form.  I can null out this automatic validation by 
> setting requires=[] on each field, but I have something like 50 fields in 
> this table.  They are not all string fields, either, so a blanket 
> requires=[] would probably screw up some of the fields.
>
> Is there a way to make the automatic validators for length handle 
> IS_EMPTY_OR correctly for fields that may be empty?
>
> -- Joe
>

-- 

--- 
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: Two tables, one form -- with a twist

2013-08-18 Thread Anthony
Also, as a general note, the automatic form names will be different for 
create vs. update forms, but you can control that by specifying your own 
form name via the "formname" argument to accepts/validate/process.

Anthony

On Sunday, August 18, 2013 6:06:20 PM UTC-7, Niphlod wrote:
>
> Given that you are pretty down the line of deciding what table needs to be 
> "touched", you should just write a wrapper that either inserts a record on 
> work_table and let the users edit it or that it copies the values from the 
> ro_table to the work_table as defaults, and then prepare a "prefilled" form 
> with fields from the work_table.
>
> pseudo_code
> if user_selected_ro:
>  values = db(db.ro_table.id == user_selected_ro).select().first()
>  .
>  for f in db.work_table.fields:
>  db.work_table[f].default = values[f]
> form = SQLFORM(db.work_table)
> .
>
> Given that some of the fields are calculated, you may want to use 
> SQLFORM.factory as well, because you'd likely want to manage the inserted 
> data a little bit before the insertion on the work_table.
>
>

-- 

--- 
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: diffrence between web2py and django framework...

2013-08-18 Thread Anthony
Have a look at this: 
http://www.quora.com/What-are-the-advantages-of-web2py-over-Django

On Friday, August 16, 2013 11:09:57 AM UTC-7, Udeme Samuel wrote:
>
> hello developers please i am new  to web2py and django but i want to know 
> what is the diffrence between the two of them and which of the framework is 
> more productive...
>

-- 

--- 
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: Two tables, one form -- with a twist

2013-08-18 Thread Joe Barnhart
Ah.  That explains one mystery.  I knew about setting the formname in the 
SQLFORM call, but I had not noticed I needed to pass it in the "validate" 
method as well.

I think perhaps Niphlod is right in that I should look towards 
SQLFORM.factory since this seems to be trending away from the average use 
of SQLFORM.

That form code is pretty hard to follow. If you start with an SQLFORM and 
call validate(), the call goes to FORM.validate() which then calls 
self.accepts(), meaning SQLFORM.accepts() in this case, which then calls 
FORM.accepts().  We do this kind of stuff all the time in Smalltalk but I'm 
not accustomed to seeing it in Python!

-- Joe

On Sunday, August 18, 2013 9:19:28 PM UTC-7, Anthony wrote:
>
> Also, as a general note, the automatic form names will be different for 
> create vs. update forms, but you can control that by specifying your own 
> form name via the "formname" argument to accepts/validate/process.
>
> Anthony
>
> On Sunday, August 18, 2013 6:06:20 PM UTC-7, Niphlod wrote:
>>
>> Given that you are pretty down the line of deciding what table needs to 
>> be "touched", you should just write a wrapper that either inserts a record 
>> on work_table and let the users edit it or that it copies the values from 
>> the ro_table to the work_table as defaults, and then prepare a "prefilled" 
>> form with fields from the work_table.
>>
>> pseudo_code
>> if user_selected_ro:
>>  values = db(db.ro_table.id == user_selected_ro).select().first()
>>  .
>>  for f in db.work_table.fields:
>>  db.work_table[f].default = values[f]
>> form = SQLFORM(db.work_table)
>> .
>>
>> Given that some of the fields are calculated, you may want to use 
>> SQLFORM.factory as well, because you'd likely want to manage the inserted 
>> data a little bit before the insertion on the work_table.
>>
>>

-- 

--- 
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: "Automatic" validators being set for tables

2013-08-18 Thread Joe Barnhart
Hi Massimo --

I think it has to do more with my abuse and misuse of SQLFORM in this case. 
 I think I'm trying to push it a little beyond its intended use model. 
 Niphlod and Anthony have been tutoring me on some approaches.  We have an 
awesome community growing up around web2py and these two are examples of 
the best.

Here is the other post:

https://groups.google.com/forum/#!topic/web2py/SjyPkAPdRPg

-- Joe

On Sunday, August 18, 2013 7:05:00 PM UTC-7, Massimo Di Pierro wrote:
>
> Can you post some code so we can reproduce it?  This should not be 
> happening. In fact the first line of the IS_LENGTH.__call__ validators 
> check for value == None and assumes length == 0
>
> On Sunday, 18 August 2013 15:42:31 UTC-5, Joe Barnhart wrote:
>>
>> I'm having problems with some automatic validators being set on my 
>> tables.  I have fields which are optional, they are NOT set as 
>> "notnull=True" and I did not provide anyvalidator -- but I DID set a length 
>> for the field, as is good practice for most databases.
>>
>> It appears those fields are being set with an automatic validator for 
>> field length, and as a consequence they are behaving as though they are 
>> "required" fields.  I get an error if the field is left empty during the 
>> validation phase of my form.  I can null out this automatic validation by 
>> setting requires=[] on each field, but I have something like 50 fields in 
>> this table.  They are not all string fields, either, so a blanket 
>> requires=[] would probably screw up some of the fields.
>>
>> Is there a way to make the automatic validators for length handle 
>> IS_EMPTY_OR correctly for fields that may be empty?
>>
>> -- Joe
>>
>

-- 

--- 
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: How to create a hyperlink from a display field in sqlForm?

2013-08-18 Thread Alex Glaros
Anthony has created a working example.  That and his analysis is listed 
below:

Massimo's solution will work if the query involves only the TaxonomyDetail 
table, but your grid involves a join, so it is necessary to include the 
tablename (i.e., record.TaxonomyDetail.objectID). But then that will fail 
if you do show a grid with only the TaxonomyDetail table. In any case, it 
is not necessary to bother with record.objectID, because that is simply the 
value of the current field, so you can use the first argument passed to the 
lambda (i.e., "id").

But there are two other problems with the above -- the link will show only 
the ID, not the objectDisplayName; and the URL() function is incorrect. 
Here's what you want:

db.TaxonomyDetail.objectID.represent = lambda id, r: 
A(db.ObjectSuperType(id).objectDisplayName,
_href=URL('manage_object_super_type', vars=dict(filter=id)))

Notice in the URL, I put the record id in a query string variable (which I 
called "filter", though any name will do). That is because passing URL args 
to the grid can get tricky -- you have to tell the grid which args in the 
URL are part of the base URL (so it can figure out which ones are for the 
grid). However, that means you must always know which args are part of the 
base URL. But if in some cases you add an arg and some cases you do not, 
then it is difficult to distinguish between those cases. My solution is to 
use a var instead of an arg so there is no confusion. Here is what the 
manage_object_super_type() function should look like:

def manage_object_super_type():
constraints = None
if request.vars.filter:
constraints = 
dict(ObjectSuperType=db.ObjectSuperType.id == 
int(request.vars.filter))
grid = SQLFORM.smartgrid(db.ObjectSuperType, constraints=constraints), 
return dict(grid=grid)

Anthony

On Tuesday, August 6, 2013 12:17:03 AM UTC-7, Johann Spies wrote:
>
> if you use Massimo's suggested code:
>
> db.TaxonomyDetail.objectID.represent =  lambda id, record:A(record.
> objectID, _target = "_blank", _href = URL('manage_object_super_type',id))
>
> Then in ' manage_object_super_type'  do something like this:
>
>
>
> def manage_object_super_type(): ## 
> data = crud.read(db.ObjectSuperType.id ==request.args(0))
> #grid = SQLFORM.smartgrid(db.ObjectSuperType), 
> #return dict(grid=grid)
> return(dict(grid=data)
>
> Regards
> Johann
>
> -- 
> Because experiencing your loyal love is better than life itself, 
> my lips will praise you.  (Psalm 63:3)
>  

-- 

--- 
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: How to identify the active .table files

2013-08-18 Thread at

quite interesting and useful knowledge for me.
thanks a lot.

On Sunday, 18 August 2013 23:11:45 UTC+5, Anthony wrote:
>
> On Sunday, August 18, 2013 2:03:47 PM UTC-4, at wrote:
>
>>
>> IC, I was not aware of that. I thought application can't be run without 
>> having a filled databases folder. So with empty folder, do we have to 
>> explicitly define *migrate=False*? and by default migrate=True?
>>
>
> Yes, by default, migrate=True. To turn off migrations for an entire DAL 
> connection, do:
>
> db = DAL(..., migrate_enabled=False)
>
> Anthony 
>

-- 

--- 
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] diffrence between web2py and django framework...

2013-08-18 Thread Emilius Omeen
deference between 
web2py - full-stack framework & 
django - non full-stack framework, but high-level Python Web framework (and 
nobody knows what it means high-level :-)
who call high-level ?
where low -level framework ?

-- 

--- 
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: How to identify the active .table files

2013-08-18 Thread Annet
Reading this raised a view questions:

Yes, by default, migrate=True. To turn off migrations for an entire DAL 
> connection, do:
>
> db = DAL(..., migrate_enabled=False)
>
>
So it is possible to have one application that just contains the model and 
another application that contains the model with migrate_enabled=False and 
the controllers and views?


What happens to the auth_ tables in this case? Except for my custom 
auth_user table their definition is outside my model files.


In case a migration in the application containing the model fails there are 
no consequences for the other application? In my table definitions I have 
migrate='table_name.table' and after migration I set migrate=False. Does 
migrate_enabled=False disable all instances of migrate='table_name.table'


According to the book before doing db = DAL(...,fake_migrate_all=True) I 
make a copy of the databases folder, after that do I empty the databases 
folder?


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