Re: [web2py] Re: ORM (?) : A Revisit, NOT a Rebuttal

2013-05-04 Thread Philip Kilner

Hi Arnon,

On 03/05/2013 23:16, Arnon Marcus wrote:

Granted, you could use the ID in a DAL context, in a similar way that
you would use an ORM-class-instance within the ORM context, but there
are other things that an ORM-object can do within an ORM context (aside
from these examples), that an ID or a Rows object can not do in the DAL
context.


OK, well I understand the parts of your reply where you have been 
explicit, but my original point was that: -


	"I truly do not understand what problem the DAL fails to solve, and I 
don't expect to without some much-less-abstract discussion."


...and I'm still none the wiser.

As a database developer with a set-oriented mind-set, the direct mapping 
to the db and explicitness of db I/O (as described by Massimo in his 
recent response) make web2py's approach an elegant and powerful solution 
to managing relational data in a relational manner. Perhaps my RDBMS 
mind-set prevents me from understanding the virtues of what you are 
proposing.


Given the complexities of implementing an ORM (not to mention your 
assertion that it is a "solved problem"), what was your take on the 
suggestion that a sensible approach would be to write an adapter for 
SQLA (or some other ORM) for the DAL?


It's not something that I would use myself, but I can see how it would 
fit into web2py, and surely that would be a more practical approach than 
developing an ORM for web2py from scratch?



--

Regards,

PhilK


e: p...@xfr.co.uk - m: 07775 796 747

'work as if you lived in the early days of a better nation'
- alasdair gray

--

--- 
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: web2py doesn't start!

2013-05-04 Thread Nader Emami
Thank you for your advice. I would explain what I have done to set-off the
IPV6 option.

Firstly I have uncomment the statement "alias net-pf-10 off #
IPv6" in  the file "/etc/modprobe.d/aliases.conf" and then run "python
web2py.py". Unfortunately without any result, I got the same error.

Then I have recompile the kernel and set-off the "IPV6" kernel.

less /usr/src/linux/.config | grep -i ipv6
# CONFIG_IPV6 is not set

Once again I tried to start "web2py.py" in recompiled kernel (without IPV6
option + alias net-pf-10 off # IPv6et in config file). It
didn't and I have gotten the same error.  I would probably say that the
problem is not the "IPV6". Naturally I am not sure!

With regards,
Nader


On 4 May 2013 01:30, 黄祥  wrote:

> I think you need to edit /etc/modprobe.d/modprobe.conf and
> /etc/modprobe.d/aliases.conf. In the files I found out this:
> *Code:*
> # Uncomment the network protocols you don't want loaded:
> # alias net-pf-2 off# IPv4
> alias net-pf-10 off   # IPv6
>
> after that please restart your network service and run python web2py.py
> again
> not tested, because i'm don't have gentoo machine, hope this can help
>
> ref:
>
> http://forums.gentoo.org/viewtopic-t-880109-view-next.html?sid=690f3daa672e303e6c7588a3b6b1591d
>
>  --
>
> ---
> 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/t_11PX-hYt0/unsubscribe?hl=en.
> 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.
>
>
>



-- 
Nader

-- 

--- 
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: ORM (?) : A Revisit, NOT a Rebuttal

2013-05-04 Thread Arnon Marcus
Yes, I have actually suggested this myself.
SQLA is layered, so it has it's ORM layer built on-top. It very well may be a 
viable option.

However, it is not entierly clear how complex it could be, since the SQLA core 
is heavilly integrated into the ORM layer.

Now, since it is all ope-source code, another option would be to try to extract 
code-chunks out of it, and reintegrate it with web2py.
That way, there may be more freedom in defining the points of intersection, as 
well as th overall API that would be exposed to the developer.

A for why it would be beneficial, I tried many approaches of explaining that, 
but it starting to be clear to me that a lot of people here have extensive 
experience in bare-SQL, so you are so used to this mined-set that it is 
difficult for you to get out of it.

It feals akin to people that have extensive experience with managed-code, that 
they are so used to doing mallocs, that after they discover some API that 
simplifies their usual manual memomry-management skills, that they can't fathom 
the benefits of having a memory-manager - it is difficult for them to trust if 
to be efficient enough. Or another example would be static-vs-dynamic 
languages. It is the tradeoff between software-performance, and 
software-developement speed and ease.

What can I say, an ORM may not be for everyone...
That said, there have been many such threads in this group over the years, so 
alought it seems in this thread that I am the only advocate of this aaproach, I 
know for a fact that it is not the case (at least it not has been the case).
So, either the other proponents of this approach, are keeping silent this time 
around, or they have left web2py behind and moved to another framework, once 
they saw it isn't gonna happen here.
The third option would be that they have been 'converted' to the DAL's way of 
thinking. The reason this option is highly unlikely, is that if that were the 
case, I would have gotten plenty comments here already, in the form of "... I 
used to be a proponent of ORM myself, and here is why I converted...".
I have not gotten a single response like that as of yet...

-- 

--- 
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: mobile menu links won't work. "%3Ca%20href="

2013-05-04 Thread BlueShadow
Hi, 
I got no clue what you mean by open a ticket.
There is no error ticket generated for this.


Am Samstag, 4. Mai 2013 00:04:15 UTC+2 schrieb Massimo Di Pierro:
>
> Please open a ticket about this.
>
> On Friday, 3 May 2013 15:43:29 UTC-5, BlueShadow wrote:
>>
>> Hi,
>> I just discovered the my menu links don't work when one uses a mobile 
>> device. they work fine with firefox chrome (I haven't tested all the other 
>> browsers but I guess they work perfectly as well). but once the user agent 
>> is mobile and the menue changes to one big drop down menu all links direct 
>> you to url/%3Ca%20href= which gives you a bad request as expected. Any 
>> ideas why this could be the case.
>> And the entries in the menu look funny too for example: Start"> 
>> Here is one line of my menu.py file:
>> response.menu = [
>> ('', 
>> False,A('Start',_href=URL('default','index'),_title="Back 
>> to the main page"), []),...
>>
>>
>>

-- 

--- 
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: ORM (?) : A Revisit, NOT a Rebuttal

2013-05-04 Thread Arnon Marcus
Also, come to think of it, it seems extremely bizarre to me, that this 
community is not receptive to the ORM concept, and here is why:
Web2py is already doing some radically-unorthodox things, architecturally, 
sometimes paying heavy-prices for it, all in order to gain more conciseness 
of code - compared to many other frameworks. So much so, in fact, that it 
historically have been a very tough sell for the python community at large, 
to accept the web2py-way of doing things - sometimes to the extreme of 
catching fire from people in the python community, not 
merely criticizing web2py but downright scorning it's developers.
So, it is hard for me to imagine web2py developers as 
these heavily-orthodox bulk-heads - it just wouldn't add up...

But perhaps I have it the other-way around - perhaps an ORM IS the 
orthodox-way of doing things, and the DAL is the unorthodox way...


-- 

--- 
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: web2py doesn't start!

2013-05-04 Thread Nader Emami
On 4 May 2013 11:09, "Nader Emami"  wrote:

> Thank you for your advice. I would explain what I have done to set-off the
> IPV6 option.
>
> Firstly I have uncomment the statement "alias net-pf-10 off #
> IPv6" in  the file "/etc/modprobe.d/aliases.conf" and then run "python
> web2py.py". Unfortunately without any result, I got the same error.
>
> Then I have recompile the kernel and set-off the "IPV6" kernel.
>
> less /usr/src/linux/.config | grep -i ipv6
> # CONFIG_IPV6 is not set
>
> Once again I tried to start "web2py.py" in recompiled kernel (without IPV6
> option + alias net-pf-10 off # IPv6et in config file). It
> didn't and I have gotten the same error.  I would probably say that the
> problem is not the "IPV6". Naturally I am not sure!
>
> With regards,
> Nader
>
>
> On 4 May 2013 01:30, 黄祥  wrote:
>
>> I think you need to edit /etc/modprobe.d/modprobe.conf and
>> /etc/modprobe.d/aliases.conf. In the files I found out this:
>> *Code:*
>> # Uncomment the network protocols you don't want loaded:
>> # alias net-pf-2 off# IPv4
>> alias net-pf-10 off   # IPv6
>>
>> after that please restart your network service and run python web2py.py
>> again
>> not tested, because i'm don't have gentoo machine, hope this can help
>>
>> ref:
>>
>> http://forums.gentoo.org/viewtopic-t-880109-view-next.html?sid=690f3daa672e303e6c7588a3b6b1591d
>>
>>  --
>>
>> ---
>> 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/t_11PX-hYt0/unsubscribe?hl=en.
>> 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.
>>
>>
>>
>
>
>
> --
> Nader
>

-- 

--- 
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: scraping utils in controller

2013-05-04 Thread Leonel Câmara
I think you should put the scraping code in a module. It's a simple 
separation of concerns thing to me. Think about it, you may like this data 
scrapped and parsed in other projects. 
  
Then in the controller/scheduler function you could import the module ask 
it to give you the new rows of the table already parsed in something 
practical like namedtuples or dicts.  
  
Depending on the table and its size the update strategy can be different. 
For instance if the table is very small (a few dozen rows) then you could 
just drop all the rows you have and just insert the new ones again without 
caring which ones changed. Otherwise maybe you can use update_or_insert (
http://www.web2py.com/book/default/chapter/06#update_or_insert) which will 
be pretty easy if you picked dicts on the previous steps.  

Sexta-feira, 3 de Maio de 2013 8:15:55 UTC+1, Timmie escreveu:
>
> Hello, 
> is there an example how to use this: 
>
> scraping utils 
> https://groups.google.com/forum/?fromgroups=#!topic/web2py/skcc2ql3zOs 
>
> in a controller? 
>
> Especially the first lines (fetching the page and getting it into an 
> element) is what I am looking for. 
>
>
> The above example is made for the shell access. 
>
> Thanks and kind regards, 
> Timmie 
>
>
>

-- 

--- 
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: ORM (?) : A Revisit, NOT a Rebuttal

2013-05-04 Thread Arnon Marcus

>
>
> Technically, it would be db.Country(Name=countryName).City(db.City.Name== 
> cityName).select().first()
> .
>
>
10x for correcting me.
 

> The way you have coded it, it is actually 6 round trips -- there are 2 
> selects per function -- one for the country, and a second for the city. But 
> that's not how you would do it in web2py anyway. Instead, you would issue 
> no selects and instead do it with just a single update -- so a total of 2 
> round trips to the db (i.e., 2 updates) :
>
> def a_child_was_born_in(countryName, cityName):
> query = (db.City.Name == cityName) & (db.City.Country.belongs(db.
> Country.Name == countryName))
> db(query).update(Population=db.City.Population + 1)
>
>
Obviously I could have done it this way, but I wanted an example that I can 
use to illustrate the differences.
Your suggestion is a circumstantial optimization to an example that is 
meant to show something else.
It is a testament to my poor example, more than it is for ORM's weaknesses.
It is before the optimization process has begun. Lets see where we go from 
here.
 

> So, in order to do the update, we do not first have to query the database 
> to retrieve the record. This is actually an advantage over the ORM, which 
> requires that you first retrieve the record before updating it.
>

That is not true. I could have done it otherwise - this is just for the 
sake of the example.
There is nothing architecturally preventing an ORM from issuing an update 
without a select.
It's an supplementation detail, not an architectural one. You may have 
encountered ORMs that can't support that, but that doesn't mean that the 
problem is in the architecture.
 

> The ORM will issue two queries to get the record if lazy loading is used, 
> or one if eager loading, a join, or a subquery is used.
>

Correct. Again, for the sake of this example.
 

> Furthermore, because web2py doesn't need to retrieve the records, it also 
> has a processing and memory advantage over the ORM, which must create the 
> record object, add it to the session, and hold it in memory.
>

That again is a circumstantial issue, pertaining to this example. In most 
cases, there would be more reuse of the objects, so creating them would be 
beneficial. Also, I don't see how in web2py's DAL it is any different - all 
of the objects you are using in the query/update are objects that has to be 
created for you to use them...
In fact, in an ORM, only the objects that are needed for the query may be 
created for each transaction, but due to how web2py is executing, you are 
actually having to create the entire-schema of objects from scratch at 
every request, so I can't see how web2py would create less-objects - it 
actually would create more...
 

>  
>
>> Now, lets say we want to optimize that, so we do a "Lazy" version of 
>> those functions.
>>
>
> There's not much to optimize here. If you don't know ahead of time that 
> you will be making two updates to the same record (which may possibly 
> negate each other),
>

No. My point here was that a lazy-query might be beneficial in some cases, 
so it could be integrated into the functions, at least optionally, and be 
chosen by the caller, based on the circumstances. It also has nothing to do 
with anticipating the override-back-to-default. You are conflating 2 
different mechanisms that are at play here.
Making it lazy, is mechanism that is being enabled by the "Identity Mapper" 
in this case, as these are two name-spaces that need to re-use the same 
object. Stick to the original example if you want to judge the 
line-of-thought - obviously it would brake down once you optimize it the 
way you have, but that's irrelevant to the example at hand.
 

> I think the minimum number of db hits is two. You could retrieve the 
> record twice, defer the first update, recognize that the second update 
> cancels the first, and then make no update -- which is still 2 hits (well, 
> 1 hit if you cache the query).
>

Again, you are completely changing the example, in order to optimize the 
use-case differently.
Obviously that is possible, but still irrelevant, as the example is a mere 
means-to-en-end of explaining something else. All you are saying here, is 
that it is a bad example, and that may be so, but it has nothing to do with 
alternative optimization approaches.
 

> Or you could just make the 2 updates (as above). In any case, I believe 
> the ORM actually requires a minimum of 4 hits (see below), so web2py is 
> still doing a lot better.
>

Wrong. (see below)
 

>
> Assuming this is SQLA, I don't think that's quite the right syntax -- it 
> appears you are creating object instances rather than issuing queries. I 
> believe it should be something like this:
>
>
This isn't SQLA - it isn't anything at this point - just a suggestion.
 

> def a_child_was_born_in(countryName, cityName):
> city = session.query(City).join(Country)\
>.filter(Country.Name == countryName)\
>.filter(City.

[web2py] Re: mobile menu links won't work. "%3Ca%20href="

2013-05-04 Thread Loïc
You can open a ticket here 
https://code.google.com/p/web2py/issues/list


Le samedi 4 mai 2013 12:47:56 UTC+2, BlueShadow a écrit :
>
> Hi, 
> I got no clue what you mean by open a ticket.
> There is no error ticket generated for this.
>
>
> Am Samstag, 4. Mai 2013 00:04:15 UTC+2 schrieb Massimo Di Pierro:
>>
>> Please open a ticket about this.
>>
>> On Friday, 3 May 2013 15:43:29 UTC-5, BlueShadow wrote:
>>>
>>> Hi,
>>> I just discovered the my menu links don't work when one uses a mobile 
>>> device. they work fine with firefox chrome (I haven't tested all the other 
>>> browsers but I guess they work perfectly as well). but once the user agent 
>>> is mobile and the menue changes to one big drop down menu all links direct 
>>> you to url/%3Ca%20href= which gives you a bad request as expected. Any 
>>> ideas why this could be the case.
>>> And the entries in the menu look funny too for example: Start"> 
>>> Here is one line of my menu.py file:
>>> response.menu = [
>>> ('', False,A('Start',_href=URL('default','index'),_title
>>> ="Back to the main page"), []),...
>>>
>>>
>>>

-- 

--- 
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: ORM (?) : A Revisit, NOT a Rebuttal

2013-05-04 Thread Anthony
It is also worth noting that when using SQLA in a web application, each 
SQLA session lasts for only a single web request. So, any benefits you may 
get from having the ORM maintain its own transaction-like session with 
identity-mapping, etc. are limited to the timescale of a single request. 
This approach is an improvement over the ActiveRecord style ORM, but it 
doesn't appear to offer much, if any, benefit over the web2py DAL, which 
does not suffer from the ActiveRecord problems.

For example, in SQLA, you might tout the ability to make multiple updates 
to a record during a session but have the changes deferred to a single 
database update. However, you can already do this in web2py by making 
multiple updates to a Row object and then calling .update_record() to send 
all the changes to the database in a single update. Of course, in web2py, 
if you obtain the record via different queries in different parts of the 
code, then you will get different Row objects (unlike in SQLA, which will 
ultimately give you back the same object), so you will have to make 
separate updates to the database for each change. However, this is also 
true in SQLA -- if you make a separate query that happens to retrieve a 
record you have previously updated in the session, the previous update will 
first be flushed to the database before the later query -- so you still end 
up with the same number of updates as in web2py.

Moreover, web2py has an additional advantage -- in web2py, if you happen to 
make a query in between making two changes to the same Row object, the 
first change to the Row object is not flushed to the database, so you can 
still limit yourself to a single db update for that Row. In SQLA, the 
intervening query would cause a flush, so you end up with more updates than 
you need. Yes, you can manually prevent the flush in SQLA if you know it 
will not do any harm, but then there's no benefit over the explicitness of 
the DAL.

Also, it's true that in SQLA, if you do two separate queries that happen to 
retrieve some of the same records, it will still only hold one copy of each 
unique record object in memory. But it still needs to pull the duplicate 
data from the database and therefore hold it in memory for some time before 
releasing it. On the other hand, in web2py you can update a record without 
first retrieving it from the database, which saves a database hit, memory, 
and processing time relative to a SQLA update.

Anthony

On Saturday, May 4, 2013 12:36:50 AM UTC-4, Anthony wrote:
>
>
> def a_child_was_born_in(countryName, cityName):
>> city = db.Country(Name=countryName).City(Name=cityName).select().
>> first()
>> city.update_record(Population=city.Population + 1)
>>
>> def a_person_has_died_in(countryName, cityName):
>> city = db.Country(Name=countryName).City(Name=cityName).select().
>> first()
>> city.update_record(Population-city.Population - 1)
>>
>  
> Technically, it would be db.Country(Name=countryName).City(db.City.Name== 
> cityName).select().first()
> .
>
> # In context 1:
>> a_child_was_born_in('France', 'Paris')
>> ...
>> # In context 2:
>> a_person_has_died_in('France', 'Paris')
>>
>> This would issue 4 round-trips to the database - 2 selects and 2 updates.
>>
>
> The way you have coded it, it is actually 6 round trips -- there are 2 
> selects per function -- one for the country, and a second for the city. But 
> that's not how you would do it in web2py anyway. Instead, you would issue 
> no selects and instead do it with just a single update -- so a total of 2 
> round trips to the db (i.e., 2 updates) :
>
> def a_child_was_born_in(countryName, cityName):
> query = (db.City.Name == cityName) & (db.City.Country.belongs(db.
> Country.Name == countryName))
> db(query).update(Population=db.City.Population + 1)
>
> So, in order to do the update, we do not first have to query the database 
> to retrieve the record. This is actually an advantage over the ORM, which 
> requires that you first retrieve the record before updating it. The ORM 
> will issue two queries to get the record if lazy loading is used, or one if 
> eager loading, a join, or a subquery is used. Furthermore, because web2py 
> doesn't need to retrieve the records, it also has a processing and memory 
> advantage over the ORM, which must create the record object, add it to the 
> session, and hold it in memory.
>  
>
>> Now, lets say we want to optimize that, so we do a "Lazy" version of 
>> those functions.
>>
>
> There's not much to optimize here. If you don't know ahead of time that 
> you will be making two updates to the same record (which may possibly 
> negate each other), I think the minimum number of db hits is two. You could 
> retrieve the record twice, defer the first update, recognize that the 
> second update cancels the first, and then make no update -- which is still 
> 2 hits (well, 1 hit if you cache the query). Or you could just make the 2 
> updates (as above). In any case, I bel

[web2py] Multi-language field content

2013-05-04 Thread Reza Shah
Hi,

I'm planning a feature which allowed the user to display the content of 
country name in english or japanese and for item_data name in english, in 
japanese(kanji) or in japanese pronunciation(kana).
The target user mostly foreigners which have basic japanese ability, they 
just use visual ability to match character written in website and in actual 
product.
In this context the text in website will be mixed with english and japanese.

With these table structure:
db.define_table('country',
Field('name1', label=T('Name'), unique=True),
Field('name2', label=T('Name(Japanese)'), unique=True),
format='%(name1)s')

db.define_table('item_data',
Field('name1', label=T('Name'), comment=T('Commercial name')),
Field('name2', label=T('Name(Romaji)'), comment=T('Product name in 
romaji')),
Field('name3', label=T('Name(Kana)'), comment=T('Product name in 
kana')),
Field('country_id', 'reference country', label=T('Country of Origin'), 
requires=IS_EMPTY_OR(IS_IN_DB(db, 'country.id', '%(name1)s', 
orderby=db.country.id, zero=T('-- Select product country --'))), 
represent=lambda id, row: db.country(id).name1 if id else ''),
format='%(name1)s')

db.define_table('setting',
Field('show_country_in_kanji')


What is the best practice for this kind of feature?
Should i create the table country and table item_data with one name 
field(english only), how to display it in japanese?
If the above structure can be used, how to display the item_data.country_id 
based on user setting  for example in japanese(kanji)?


Thanks,
Reza

-- 

--- 
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: web2py doesn't start!

2013-05-04 Thread Jonathan Lundell
On 4 May 2013, at 2:09 AM, Nader Emami  wrote:
> Thank you for your advice. I would explain what I have done to set-off the 
> IPV6 option. 
> 
> Firstly I have uncomment the statement "alias net-pf-10 off # 
> IPv6" in  the file "/etc/modprobe.d/aliases.conf" and then run "python 
> web2py.py". Unfortunately without any result, I got the same error.
> 
> Then I have recompile the kernel and set-off the "IPV6" kernel. 
> 
> less /usr/src/linux/.config | grep -i ipv6
> # CONFIG_IPV6 is not set
> 
> Once again I tried to start "web2py.py" in recompiled kernel (without IPV6 
> option + alias net-pf-10 off # IPv6et in config file). It didn't 
> and I have gotten the same error.  I would probably say that the problem is 
> not the "IPV6". Naturally I am not sure! 

If you can, please try the current trunk; it has a patch that should fix the 
problem.

-- 

--- 
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] Scheduler - calling functions outside a model?

2013-05-04 Thread Simon Ashley
Have a query on the scheduler and whether functions need to be defined 
inside a model or can be offload to a controller?

(have seen a passing comment by Niphlod - which I can no longer find - that 
it may not be the case with ComfortScheduler but haven't been able to 
confirm it or worked out how to do it). 

Have a job that requires extensive parsing and file transformations. For 
performance reasons wouldn't like these extensive routines (estimated at 4 
-5k lines) being loaded each time a task is fetched.

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: Multi-language field content

2013-05-04 Thread 黄祥
imho, i think your define table is redundant if you do like your post above 
e.g. field name1 is redundant with name2.
i think it can be achieve you only create 1 table field called name and 
translate it using T(). define the japanese language translation on the 
languages folder and create new file (jp-romaji.py, jp-kanji.py, 
jp-hiragana.py, jp-katakana.py) after that create the language selector 
like in the admin page.
if you want to set the default language for japanese language (romaji or 
kanji or hiragana or katakana), you can replace the layout.html in the 
views folder
e.g.

for example replace with the japanese file that you've define before 
(jp-romaji.py, jp-kanji.py, jp-hiragana.py, jp-katakana.py)


hope this can help

best regards

On Saturday, May 4, 2013 9:42:05 AM UTC-4, Reza Shah wrote:
>
> Hi,
>
> I'm planning a feature which allowed the user to display the content of 
> country name in english or japanese and for item_data name in english, in 
> japanese(kanji) or in japanese pronunciation(kana).
> The target user mostly foreigners which have basic japanese ability, they 
> just use visual ability to match character written in website and in actual 
> product.
> In this context the text in website will be mixed with english and 
> japanese.
>
> With these table structure:
> db.define_table('country',
> Field('name1', label=T('Name'), unique=True),
> Field('name2', label=T('Name(Japanese)'), unique=True),
> format='%(name1)s')
>
> db.define_table('item_data',
> Field('name1', label=T('Name'), comment=T('Commercial name')),
> Field('name2', label=T('Name(Romaji)'), comment=T('Product name in 
> romaji')),
> Field('name3', label=T('Name(Kana)'), comment=T('Product name in 
> kana')),
> Field('country_id', 'reference country', label=T('Country of Origin'), 
> requires=IS_EMPTY_OR(IS_IN_DB(db, 'country.id', '%(name1)s', orderby=
> db.country.id, zero=T('-- Select product country --'))), represent=lambda 
> id, row: db.country(id).name1 if id else ''),
> format='%(name1)s')
>
> db.define_table('setting',
> Field('show_country_in_kanji')
>
>
> What is the best practice for this kind of feature?
> Should i create the table country and table item_data with one name 
> field(english only), how to display it in japanese?
> If the above structure can be used, how to display the 
> item_data.country_id based on user setting  for example in japanese(kanji)?
>
>
> Thanks,
> Reza
>

-- 

--- 
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: Scheduler - calling functions outside a model?

2013-05-04 Thread Niphlod
I'm not sure I understood your requirements... how can a "controller" 
function can be scheduled as a task?
On the last comma you talk about extensive routines: aren't they in a 
module ?

On Saturday, May 4, 2013 4:12:21 PM UTC+2, Simon Ashley wrote:
>
> Have a query on the scheduler and whether functions need to be defined 
> inside a model or can be offload to a controller?
>
> (have seen a passing comment by Niphlod - which I can no longer find - 
> that it may not be the case with ComfortScheduler but haven't been able to 
> confirm it or worked out how to do it). 
>
> Have a job that requires extensive parsing and file transformations. For 
> performance reasons wouldn't like these extensive routines (estimated at 4 
> -5k lines) being loaded each time a task is fetched.
>
> 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] Re: web2py doesn't start!

2013-05-04 Thread Nader Emami
which "trunk"? I don't see any one!


On 4 May 2013 16:10, Jonathan Lundell  wrote:

> On 4 May 2013, at 2:09 AM, Nader Emami  wrote:
>
> Thank you for your advice. I would explain what I have done to set-off the
> IPV6 option.
>
> Firstly I have uncomment the statement "alias net-pf-10 off #
> IPv6" in  the file "/etc/modprobe.d/aliases.conf" and then run "python
> web2py.py". Unfortunately without any result, I got the same error.
>
> Then I have recompile the kernel and set-off the "IPV6" kernel.
>
> less /usr/src/linux/.config | grep -i ipv6
> # CONFIG_IPV6 is not set
>
> Once again I tried to start "web2py.py" in recompiled kernel (without IPV6
> option + alias net-pf-10 off # IPv6et in config file). It
> didn't and I have gotten the same error.  I would probably say that the
> problem is not the "IPV6". Naturally I am not sure!
>
>
> If you can, please try the current trunk; it has a patch that should fix
> the problem.
>
> --
>
> ---
> 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/t_11PX-hYt0/unsubscribe?hl=en.
> 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.
>
>
>



-- 
Nader

-- 

--- 
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: web2py doesn't start!

2013-05-04 Thread 黄祥
please go to 
http://web2py.com/init/default/download
and then click source code in for testers coloumn

On Saturday, May 4, 2013 10:43:26 AM UTC-4, Nader Emami wrote:
>
> which "trunk"? I don't see any one!
>
>
> On 4 May 2013 16:10, Jonathan Lundell >wrote:
>
>> On 4 May 2013, at 2:09 AM, Nader Emami > 
>> wrote:
>>
>> Thank you for your advice. I would explain what I have done to set-off 
>> the IPV6 option. 
>>
>> Firstly I have uncomment the statement "alias net-pf-10 off # 
>> IPv6" in  the file "/etc/modprobe.d/aliases.conf" and then run "python 
>> web2py.py". Unfortunately without any result, I got the same error.
>>
>> Then I have recompile the kernel and set-off the "IPV6" kernel. 
>>
>> less /usr/src/linux/.config | grep -i ipv6
>> # CONFIG_IPV6 is not set
>>  
>> Once again I tried to start "web2py.py" in recompiled kernel (without 
>> IPV6 option + alias net-pf-10 off # IPv6et in config file). It 
>> didn't and I have gotten the same error.  I would probably say that the 
>> problem is not the "IPV6". Naturally I am not sure! 
>>
>>
>> If you can, please try the current trunk; it has a patch that should fix 
>> the problem.
>>
>> -- 
>>  
>> --- 
>> 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/t_11PX-hYt0/unsubscribe?hl=en.
>> To unsubscribe from this group and all its topics, send an email to 
>> web2py+un...@googlegroups.com .
>> For more options, visit https://groups.google.com/groups/opt_out.
>>  
>>  
>>
>
>
>
> -- 
> Nader 
>

-- 

--- 
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: scraping utils in controller

2013-05-04 Thread villas
> Actually, at the moment, the above will generate an error because 
apparently there is an unbalanced  tag somewhere on the web2py.com page.

Yes scraping real-life websites is frustrating because so much html is 
broken.  In the end I achieved reasonable success with Beautifulsoup.  
However,  I also understand that Scrapy is good and I was thinking of using 
that for a future project.



 

> On Friday, May 3, 2013 3:15:55 AM UTC-4, Timmie wrote:
>>
>> Hello, 
>> is there an example how to use this: 
>>
>> scraping utils 
>> https://groups.google.com/forum/?fromgroups=#!topic/web2py/skcc2ql3zOs 
>>
>> in a controller? 
>>
>> Especially the first lines (fetching the page and getting it into an 
>> element) is what I am looking for. 
>>
>>
>> The above example is made for the shell access. 
>>
>> Thanks and kind regards, 
>> Timmie 
>>
>>
>>

-- 

--- 
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] Web2py ->Eclipse->Pyodbc

2013-05-04 Thread v1s
Hello All,

I have been using web2py for a few days now and its really good. I wish to 
now set up an the environment in eclipse and run web2py from there.

Currently i am using eclipse with pydev plugin and pyodbc for databse 
access to sql server. Is there a good tutorial which explains me on how to 
achieve this. I have followed a few online tutorials and i always end up on:

Import Error: DLL load failed: %1 is not a valid Win32 application..

Any suggestions or thoughts?

Thanks

-- 

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




[web2py] Re: Web2py ->Eclipse->Pyodbc

2013-05-04 Thread Massimo Di Pierro
I just came across this: https://code.google.com/p/neo-web2py2eclipse/
I did not try it. Does it help?

On Saturday, 4 May 2013 10:44:33 UTC-5, v1s wrote:
>
> Hello All,
>
> I have been using web2py for a few days now and its really good. I wish to 
> now set up an the environment in eclipse and run web2py from there.
>
> Currently i am using eclipse with pydev plugin and pyodbc for databse 
> access to sql server. Is there a good tutorial which explains me on how to 
> achieve this. I have followed a few online tutorials and i always end up on:
>
> Import Error: DLL load failed: %1 is not a valid Win32 application..
>
> Any suggestions or thoughts?
>
> Thanks
>

-- 

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




[web2py] Re: Unable to store incremented values in data store as a next record

2013-05-04 Thread Massimo Di Pierro
What's the model? The "incrementation" must be done at the web2py level not 
the db level since not all DBs support time shifting.

On Friday, 3 May 2013 00:24:58 UTC-5, Mukesh Gaur wrote:
>
> Hi,
>
> I am facing below challenges/ issue:
>
> 1.   Unable to store incremented start date and related information 
> in a database because of existing functionality/ limitations.
>
> For example: if an event start date is 2013-05-01 and end date is  
> 2013-05-04. In this case we need to store:
>
> 1.   2013-05-01
>
> 2.   2013-05-02
>
> 3.   2013-05-03
>
> 4.   2013-05-04
>
>  We are able to store only 2013-05-01 as start date and 2013-05-04 as end 
> date.
>
> Logically, we have incremented and got all related required information 
> and able to see  in a program logs but not able store these values in a 
> database
>

-- 

--- 
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: ORM (?) : A Revisit, NOT a Rebuttal

2013-05-04 Thread Arnon Marcus


On Saturday, May 4, 2013 6:07:21 AM UTC-7, Anthony wrote:
>
> It is also worth noting that when using SQLA in a web application, each 
> SQLA session lasts for only a single web request. So, any benefits you may 
> get from having the ORM maintain its own transaction-like session with 
> identity-mapping, etc. are limited to the timescale of a single request. 
> This approach is an improvement over the ActiveRecord style ORM, but it 
> doesn't appear to offer much, if any, benefit over the web2py DAL, which 
> does not suffer from the ActiveRecord problems.
>
> For example, in SQLA, you might tout the ability to make multiple updates 
> to a record during a session but have the changes deferred to a single 
> database update. However, you can already do this in web2py by making 
> multiple updates to a Row object and then calling .update_record() to send 
> all the changes to the database in a single update. Of course, in web2py, 
> if you obtain the record via different queries in different parts of the 
> code, then you will get different Row objects (unlike in SQLA, which will 
> ultimately give you back the same object), so you will have to make 
> separate updates to the database for each change. However, this is also 
> true in SQLA -- if you make a separate query that happens to retrieve a 
> record you have previously updated in the session, the previous update will 
> first be flushed to the database before the later query -- so you still end 
> up with the same number of updates as in web2py.
>

Not i you deactivate auto-flushing.
 

>
> Moreover, web2py has an additional advantage -- in web2py, if you happen 
> to make a query in between making two changes to the same Row object, the 
> first change to the Row object is not flushed to the database, so you can 
> still limit yourself to a single db update for that Row. In SQLA, the 
> intervening query would cause a flush, so you end up with more updates than 
> you need. Yes, you can manually prevent the flush in SQLA if you know it 
> will not do any harm, but then there's no benefit over the explicitness of 
> the DAL.
>

You will not get the benefit of auto-flushing for these 
operations, obviousely, because you turned it off explicitly.
But it is EXACTLY in order to GAIN a benefit of Lazy-Updates ACROSS 
NAME-SAPCES - that you temporarily turned it odd - which is something that 
web2py CAN NOT DO. Ultimately, get a SINGLE-DATABASE hit in this example, 
whereas using web2py you would get TWO hits.
 

>
> Also, it's true that in SQLA, if you do two separate queries that happen 
> to retrieve some of the same records, it will still only hold one copy of 
> each unique record object in memory. But it still needs to pull the 
> duplicate data from the database and therefore hold it in memory for some 
> time before releasing
>

For this example, yes, but it is worth is because you are saving a 
round-trip to the database, when compared to web2py. For other cases, you 
may still do an update-without-select in SQLA also, using the SQLA-Core 
directly. You wont get the benefits of an ORM this way, but you will also 
loose the ability so save yourself a database-hit, and will be back in 
web2py's DAL land, so you didn't WIN anything from an ORM like that, but 
you also didn't lose anything that web2py can do that SQLA can't.
 

> it. On the other hand, in web2py you can update a record without first 
> retrieving it from the database, which saves a database hit, memory, and 
> processing time relative to a SQLA update.
>

It saves a hit to the database, in exactly the same manner that an 
SQLA-Lazy-Update would do (with auto-flushing temporarily turned off). But 
the Unit-Of-Work pattern, in conjunction with the Identity-Map, then saves 
you ANOTHER hit to the database, in this case, when it is concluded that no 
change is needed, THAT you CAN NOT do in web2py in this case, since the two 
Rows object do not know about each other, and so the 
back-to-previouse-value check thing can not be detected.

One more thing -  the auto-flush disabling does not have to be decided 
ahead of time at session-creation (though you can also do that). You can 
always just tick the flag on and off in runtime, so you could potentially 
get the nest of both worlds even within a transaction, if you are doing 
other things in it befire this example occurs, that benefit from 
auto-flushing.
 

>
> Anthony
>
> On Saturday, May 4, 2013 12:36:50 AM UTC-4, Anthony wrote:
>>
>>
>> def a_child_was_born_in(countryName, cityName):
>>> city = db.Country(Name=countryName).City(Name=cityName).select().
>>> first()
>>> city.update_record(Population=city.Population + 1)
>>>
>>> def a_person_has_died_in(countryName, cityName):
>>> city = db.Country(Name=countryName).City(Name=cityName).select().
>>> first()
>>> city.update_record(Population-city.Population - 1)
>>>
>>  
>> Technically, it would be db.Country(Name=countryName).City(db.City.Name== 
>> cityName).select().fi

[web2py] Re: ORM (?) : A Revisit, NOT a Rebuttal

2013-05-04 Thread Anthony


> def a_child_was_born_in(countryName, cityName):
>> query = (db.City.Name == cityName) & (db.City.Country.belongs(db.
>> Country.Name == countryName))
>> db(query).update(Population=db.City.Population + 1)
>>
>>
> Obviously I could have done it this way, but I wanted an example that I 
> can use to illustrate the differences.
> Your suggestion is a circumstantial optimization to an example that is 
> meant to show something else.
>

Arnon, we have repeatedly asked you to offer use cases where the ORM will 
be either easier or more efficient than the DAL. In this case, you have 
concocted an example that makes it appear that the ORM has advantages, but 
only because you have used the DAL in the least efficient way possible. If 
your requirement in making comparisons is that the DAL must be required to 
do everything in the same fashion as the ORM, then this is nonsensical. The 
question should be whether the DAL can achieve the same outcome just as 
easily (i.e., code that is similarly easy to produce, understand, test, 
debug, etc.) and with similar efficiency. There's no reason the DAL code 
should therefore have to superficially resemble the ORM code or precisely 
replicate its operations.

Now, you might argue that this is just a bad example, and that there is 
some real-world example where the web2py DAL will be forced to do something 
like you have coded here, and that's where the ORM will have an advantage. 
If that's the case, then you should have no problem presenting such an 
example. If you cannot do so, then it is hard to take this seriously.
  

> So, in order to do the update, we do not first have to query the database 
>> to retrieve the record. This is actually an advantage over the ORM, which 
>> requires that you first retrieve the record before updating it.
>>
>
> That is not true. I could have done it otherwise - this is just for the 
> sake of the example.
> There is nothing architecturally preventing an ORM from issuing an update 
> without a select. 
>
It's an supplementation detail, not an architectural one. You may have 
> encountered ORMs that can't support that, but that doesn't mean that the 
> problem is in the architecture.
>

As far as I can tell, if you want to update a record in SQLA, you must 
first retrieve it from the database (if using the ORM). If you believe that 
is not the case, then please show the code for how you would do this in the 
ORM.

As for the architectural issue, I suppose in principle an ORM could update 
a record without a prior select, but then you lose the other benefits of 
the ORM, as you will not have an object representation of that updated 
record in Python. At this point, you might as well have a DAL. In other 
words, if both the ORM and the DAL handle this case via direct database 
updates, then this example is irrelevant for establishing the supposed 
advantages of an ORM.
 

> Furthermore, because web2py doesn't need to retrieve the records, it also 
>> has a processing and memory advantage over the ORM, which must create the 
>> record object, add it to the session, and hold it in memory.
>>
>
> That again is a circumstantial issue, pertaining to this example. In most 
> cases, there would be more reuse of the objects, so creating them would be 
> beneficial.
>

In web2py, you create the objects when you need them. You do not always 
need them. For example, if you are updating a record, you might retrieve it 
in one request, then update it in a second request -- no need for another 
retrieval in the second request (unless you want to check for intervening 
changes).
 

> Also, I don't see how in web2py's DAL it is any different - all of the 
> objects you are using in the query/update are objects that has to be 
> created for you to use them...
>

No, in web2py, you do not need to create a Row object in order to update a 
record in the database.
 

> In fact, in an ORM, only the objects that are needed for the query may be 
> created for each transaction, but due to how web2py is executing, you are 
> actually having to create the entire-schema of objects from scratch at 
> every request, so I can't see how web2py would create less-objects - it 
> actually would create more...
>

Not sure what you're talking about here. If you are talking about defining 
tables in web2py at every request, it is not required that you define all 
the tables for the entire schema -- you can define conditionally depending 
on what you need. If you are talking about creating instances of Row 
objects, then you are mistaken -- only those you explicitly create are 
created, and exactly when you explicitly create them.
 

> Now, lets say we want to optimize that, so we do a "Lazy" version of those 
>>> functions.
>>>
>>
>> There's not much to optimize here. If you don't know ahead of time that 
>> you will be making two updates to the same record (which may possibly 
>> negate each other),
>>
>
> No. My point here was that a lazy-query might be beneficial

[web2py] Re: ORM (?) : A Revisit, NOT a Rebuttal

2013-05-04 Thread Massimo Di Pierro
In web2py we assume the code within one transaction is 
executed sequentially. When you say "being used by different contexts 
within the same transaction" you seem two assume different threads may act 
on data within the same transaction. I think going that rout is dangerous 
and should not be encouraged.

On Friday, 3 May 2013 18:41:47 UTC-5, Arnon Marcus wrote:
>
> Here is a use-case that can benefit from an ORM.
> Let's say we have 2 functions that manipulate the same field in 2 
> different functions.
>
> Here is how it would be done using the DAL:
>
> def a_child_was_born_in(countryName, cityName):
> city = db.Country(Name=countryName).City(Name=cityName).select().first
> ()
> city.update_record(Population=city.Population + 1)
>
> def a_person_has_died_in(countryName, cityName):
> city = db.Country(Name=countryName).City(Name=cityName).select().first
> ()
> city.update_record(Population-city.Population - 1)
>
> Now, let's say that both functions are being used by different contexts 
> within the same transaction (hypothetically, say, from some different 
> functions, way deep in the call stack).
>
> # In context 1:
> a_child_was_born_in('France', 'Paris')
> ...
> # In context 2:
> a_person_has_died_in('France', 'Paris')
>
> This would issue 4 round-trips to the database - 2 selects and 2 updates.
>
> Now, lets say we want to optimize that, so we do a "Lazy" version of those 
> functions.
> How would we go about doing that?
> Well, we "could" replace the ".update_record" with an ".update".
>
> def a_child_was_born_in(countryName, cityName):
> city = db.Country(Name=countryName).City(Name=cityName).select().first
> ()
> city.update(Population=city.Population + 1)
>
> def a_person_has_died_in(countryName, cityName):
> city = db.Country(Name=countryName).City(Name=cityName).select().first
> ()
> city.update(Population-city.Population - 1)
>
> Would that work?
> Well, let's see, assuming the initial population value of Paris, is 2 
> million.
> When a child is born, the value would get incremented locally.
> But the Row object of the 'city' variable is not persisted in memory when 
> the functions return.
> So we need to commit the transaction after each call.
> But wait a minute, that would get us back to 4 operations... Might as well 
> leave the update_record the way it was.
> What do we do?
> Well, we could make the laziness "optional", and call the first one 
> eagerly and the second lazily.
> Yes, we would need to keep track of our ordering of calling them, but if 
> we do it right, we could get it down to 3 operations (2 selects and one 
> update).
> Would that work?
> Well, no, because then we would loose the second update once the second 
> function returns...
> Can we still do something?
> Well, yes, we can activate caching on the City field, so 
> it's internal-values would survive across transactions - given that we give 
> the cache a long-enough time-out.
> This may not help us in the updates, but it could nock-off a the second 
> query (he select operation in the second function)
> So the best we get is 3 operations - 1 select and 2 updates.
>
> Now, here is the same code, using an ORM:
>
> def a_child_was_born_in(countryName, cityName):
> city = Country(Name=countryName).City(Name=cityName)
> city.Population += 1
>
>
> def a_person_has_died_in(countryName, cityName):
> city = Country(Name=countryName).City(Name=cityName)
> city.Population -= 1
>
> The syntactic difference is small, but the semantic implication is 
> profound.
>
> The automatic cache-mechanism in the ORM will detect that we 
> are querying the same record, and so would not query the database in the 
> second function - just return the same object already in memory.
> So now we're down to 3 actual operations - 1 select and 2 updates.
>
> But it doesn't stop there...
> In the DAL case, we cached the "values" inside the city field, but the 
> 'city' variable in the first function, is still a separate Rows object from 
> the 'city' object in the second function, so we couldn't do Lazy updates.
> But an ORM can have an "Identity Mapper", that would make sure they the 
> same object would be returned,
> It would be bound to two different name-spaces, but it would be the same 
> object.
> Now we could implement a "Truely" lazy update. The increment that is done 
> in the first function, would be reflected in the second one, because the 
> same object would be returned,
>
> So now we're sown to 2 operations - one select, and one update - the 
> update would automatically be issued for us at transaction-commit time, as 
> it would be balled "pending" by the time it get's there, using the 
> "Unit-of-Work" pattern..
>
> But it doesn't have to even stop there...
> The "Unit-of-Work" mechanism has this "dirty" label, which signifies that 
> the current value within a record-object has different value from the one 
> in the database. Now, it may be implemented poorly, and just get flagged 

[web2py] Re: ORM (?) : A Revisit, NOT a Rebuttal

2013-05-04 Thread Anthony


> However, this is also true in SQLA -- if you make a separate query that 
>> happens to retrieve a record you have previously updated in the session, 
>> the previous update will first be flushed to the database before the later 
>> query -- so you still end up with the same number of updates as in web2py.
>>
>
> Not i you deactivate auto-flushing.
>

Yes, but it's on by default for a reason. You have to be careful about when 
you disable auto-flushing, or otherwise switch to manual flushing 
everywhere.
 

> You will not get the benefit of auto-flushing for these 
> operations, obviousely, because you turned it off explicitly.
> But it is EXACTLY in order to GAIN a benefit of Lazy-Updates ACROSS 
> NAME-SAPCES - that you temporarily turned it odd - which is something that 
> web2py CAN NOT DO. Ultimately, get a SINGLE-DATABASE hit in this example, 
> whereas using web2py you would get TWO hits.
>

Well, 3 database hits for the ORM, counting the 2 selects. But how do you 
know you can turn off auto-flushing in this example? What if a record was 
inserted in between the first function call and the second, and that's the 
record that needs to be updated in the second function? In that case, the 
second call will fail to make its update.

Anyway, if you have a scenario like this where you know you're likely to be 
making multiple updates to the same record within the same web request, but 
you have to retrieve that record via separate queries in different parts of 
your code, I suppose you could build a basic identity map that stores 
queried rows by PK and does a lookup upon subsequent queries, just like 
SQLA. This doesn't require an ORM. I'm not sure you would want to do it 
automatically all the time, though, as there would be memory and processing 
overhead associated with keeping everything in such a structure, which 
would not be used most of the time.

Also, it's true that in SQLA, if you do two separate queries that happen to 
>> retrieve some of the same records, it will still only hold one copy of each 
>> unique record object in memory. But it still needs to pull the duplicate 
>> data from the database and therefore hold it in memory for some time before 
>> releasing
>>
>
> For this example, yes, but it is worth is because you are saving a 
> round-trip to the database, when compared to web2py.
>

You claimed that keeping only one copy of the object means you save memory 
-- I was just pointing out that at least the data used to create the object 
does in fact get duplicated in memory for a time. Furthermore, SQLA will 
keep *all* objects in memory throughout the session, whereas web2py may 
release objects when they go out of scope and are no longer needed.
 

> But the Unit-Of-Work pattern, in conjunction with the Identity-Map, then 
> saves you ANOTHER hit to the database, in this case, when it is concluded 
> that no change is needed, THAT you CAN NOT do in web2py in this case, since 
> the two Rows object do not know about each other, and so the 
> back-to-previouse-value check thing can not be detected.
>

Does SQLA do a back-to-previous-value check -- I haven't seen anything 
about that? Anyway, at best that gets you down to 2 database hits, assuming 
you can solve the flushing problem (see above).

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] Re: ORM (?) : A Revisit, NOT a Rebuttal

2013-05-04 Thread Arnon Marcus
No, I am not assuming that.
Different contexes can, and actually often do, exisr within a serially run 
single-thrrad. The difference in contexts lie in the different namespaces being 
generated by the mere action of calling a function.
I am not edorcing multythreading by any means, but even if I was, that kind of 
worrie would still be unjustified, as the different thread would use a 
different transaction.

-- 

--- 
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: ORM (?) : A Revisit, NOT a Rebuttal

2013-05-04 Thread Arnon Marcus
No, I am not assuming that.
Different contexes can, and actually often do, exisr within a serially run 
single-thrrad. The difference in contexts lie in the different namespaces being 
generated by the mere action of calling a function.
I am not edorcing multythreading by any means, but even if I was, that kind of 
worrie would still be unjustified, as the different thread would use a 
different transaction.

-- 

--- 
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: ORM (?) : A Revisit, NOT a Rebuttal

2013-05-04 Thread Arnon Marcus
No, I am not assuming that.
Different contexes can, and actually often do, exisr within a serially run 
single-thrrad. The difference in contexts lie in the different namespaces being 
generated by the mere action of calling a function.
I am not edorcing multythreading by any means, but even if I was, that kind of 
worrie would still be unjustified, as the different thread would use a 
different transaction.

-- 

--- 
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] data into row

2013-05-04 Thread lucas
hello one and all,

i need the most efficient way to convert raw data into a row of a specific 
format.  what is the most efficient way to do this in python.  yes, 
probably more a python question then web2py.

anyway, a bit more details, right now i pass a row from a table to a 
function and the function processes the data in that row through a complex 
series of calculations.  i have a variation of the data coming from another 
source and instead of rewriting a perfectly good function, i would like to 
mangle and convert that data into the same row specifications and pass it 
through the same function.  this way the function can't tell the difference 
of where the data is coming from, it just processes the data in that row 
the same way.  make sense?

so what is the best way to do this?  thanx in advance, lucas

-- 

--- 
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: Scheduler - calling functions outside a model?

2013-05-04 Thread Simon Ashley
Thanks Niphlod ..

1. yes - a 'controller function" scheduled as a task.
2. routines are in controllers, rather than modules. (some calculations/ 
transforms may change regularly)

On Sunday, 5 May 2013 00:25:30 UTC+10, Niphlod wrote:
>
> I'm not sure I understood your requirements... how can a "controller" 
> function can be scheduled as a task?
> On the last comma you talk about extensive routines: aren't they in a 
> module ?
>
> On Saturday, May 4, 2013 4:12:21 PM UTC+2, Simon Ashley wrote:
>>
>> Have a query on the scheduler and whether functions need to be defined 
>> inside a model or can be offload to a controller?
>>
>> (have seen a passing comment by Niphlod - which I can no longer find - 
>> that it may not be the case with ComfortScheduler but haven't been able to 
>> confirm it or worked out how to do it). 
>>
>> Have a job that requires extensive parsing and file transformations. For 
>> performance reasons wouldn't like these extensive routines (estimated at 4 
>> -5k lines) being loaded each time a task is fetched.
>>
>> 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: web2py resources

2013-05-04 Thread Fabiano
This thread has a very useful collection references and resources.

I've seen a lot of great stuff on this list but over time it gets harder to 
dig the mailing due the high amount of messages. I understand somethings 
don't fit on the main website and putting things in there requires some 
effort and overhead (review, maintenance, access, etc.).

Have you guys considered using a wiki for this kind of stuff? I think this 
kind of information could easily be placed in there and maintained by the 
community.

The Google Code project hosting where the Issues tracker is already has a 
wiki which could be used, so there is no need to setup one.

What you think of this suggestion?

Fabiano.

On Monday, April 30, 2012 4:49:41 PM UTC-3, Anthony wrote:
>
> Most web2py resources can be found on web2py.com, but here are some 
> Google Groups topics identifying additional resources:
>
> web2py help & 
> resources
> Plugins
> Signature 
> apps
> Featured web2py 
> apps
> web2py 
> hosting
>

-- 

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




[web2py] Re: web2py resources

2013-05-04 Thread Anthony
You can post recipes and articles here: 
http://www.web2pyslices.com/slice/show/1583/web2py-environment-globals-and-locals-objects.
 
There was at least one wiki in the past, but it became neglected and 
ultimately abandoned.

Anthony

On Saturday, May 4, 2013 6:38:01 PM UTC-4, Fabiano wrote:
>
> This thread has a very useful collection references and resources.
>
> I've seen a lot of great stuff on this list but over time it gets harder 
> to dig the mailing due the high amount of messages. I understand somethings 
> don't fit on the main website and putting things in there requires some 
> effort and overhead (review, maintenance, access, etc.).
>
> Have you guys considered using a wiki for this kind of stuff? I think this 
> kind of information could easily be placed in there and maintained by the 
> community.
>
> The Google Code project hosting where the Issues tracker is already has a 
> wiki which could be used, so there is no need to setup one.
>
> What you think of this suggestion?
>
> Fabiano.
>
> On Monday, April 30, 2012 4:49:41 PM UTC-3, Anthony wrote:
>>
>> Most web2py resources can be found on web2py.com, but here are some 
>> Google Groups topics identifying additional resources:
>>
>> web2py help & 
>> resources
>> Plugins
>> Signature 
>> apps
>> Featured web2py 
>> apps
>> web2py 
>> hosting
>>
>

-- 

--- 
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: ORM (?) : A Revisit, NOT a Rebuttal

2013-05-04 Thread Arnon Marcus


> Now, you might argue that this is just a bad example, and that there is 
> some real-world example where the web2py DAL will be forced to do something 
> like you have coded here, and that's where the ORM will have an advantage. 
> If that's the case, then you should have no problem presenting such an 
> example. If you cannot do so, then it is hard to take this seriously.
>

My difficulty/reluctance to finding more/better examples, are a testament 
to my poor expertise  Nothing more, nothing less.

>
> As far as I can tell, if you want to update a record in SQLA, you must 
> first retrieve it from the database (if using the ORM). If you believe that 
> is not the case, then please show the code for how you would do this in the 
> ORM.
>

I am already stretched way beyond my expertise, here, which is an 
interesting exerciser, but I can't stretch that to the point you are asking 
me to.
I see no logical-fault in my suggestion, so irrespective of where this 
logic is implemented, irrespective of weather it is implemented in SQLA, 
and irrespectively of my ability to implement a prototype that would do 
that, the logic appears to be sound. There is no logical-reason you could 
not generate an object-graph out of the query you are constructing, Only 
the benefits of that are questionable, and that may be extremely 
circumstantial and complicated to benchmark, so U am not going to do that. 
There are other people (presumably in this group as well), who are much 
more proficient and experienced in doing so.
I will elaborate on where I think my logic is sound, further on, and show 
you what you are missing.
 

>
> As for the architectural issue, I suppose in principle an ORM could update 
> a record without a prior select, but then you lose the other benefits of 
> the ORM, as you will not have an object representation of that updated 
> record in Python.
>

You are assuming a circumstancial-implementation that is not doing what I 
have suggested. If the update operation would generate an object-graph, 
representing what it is assuming is existing in the database "schema wise", 
then I see no reason why it should not be able to store the data tha it is 
udpating (or even inserting). Remember, we are talking about a context of 
an atomic transaction, so an ORM is logically safe in assuming that the 
transaction will complete successfully - it's called "optimistic updates". 
The reason for this safety, is that the object-graph that is being created 
in the transaction is being tracked, so a rollback, in an event of 
transaction commit-failure, is going to dump these object anyways... More 
so, the ORM is aware of the database schema, so it could infet the validity 
of the structure of the object-graph it would generate.
 

> At this point, you might as well have a DAL. In other words, if both the 
> ORM and the DAL handle this case via direct database updates, then this 
> example is irrelevant for establishing the supposed advantages of an ORM.
>

True for SQLA.
Not true in what I am proposing.
 

>
> In web2py, you create the objects when you need them. You do not always 
> need them. For example, if you are updating a record, you might retrieve it 
> in one request, then update it in a second request -- no need for another 
> retrieval in the second request (unless you want to check for intervening 
> changes).
>

What I meant by that is that this example is not showing much reuse within 
the same transaction, so your argument that object-creation, may not be 
that beneficial, is valid in this example.
However, the whole point in having an ORM, is for cases you DO have many 
reuses of record-objects within a transaction. In these cases, an ORM is 
more beneficial. In other cases, thr DAL would be more beneficial. The mere 
fact that even with an ORM, there would still exist circumstances in which 
it would be less efficient, is not a testament to the ORM's uslessness...
By that logic, the mere existence of circumstances in which "walking" would 
be more efficient than "driving a car", is somehow a testament to a 
car's uselessness...
For circumstances in which the DAL would be more efficient - by all means 
"use it" - it is not going anywhere (!) That's what SQLA users are doing 
(at leas I hope...)
Again, it is only a testament to the poorness of my example - that's it.
 

>
> No, in web2py, you do not need to create a Row object in order to update a 
> record in the database.
>

I meant the objects that the DAL is creating for it's internal 
functionality - on the fly - they are akin to the objects that an ORM would 
create to implement it's functionality - on the fly... The fact that an ROM 
would create slightly more record-objects than web2py would create, it not 
necessarily a bad point for an ORM - again, you can dissect any framework 
and find inefficiencies linke that everywhere, if you like -  it may mean 
something and may not - there are multiple trade-off being taken in 
multiple levels, for th

[web2py] Developers/contributors guidelines?

2013-05-04 Thread Fabiano Engler
Hi all,

I have looked for some information on how web2py is developed and
maintained, I found some bits of info here and there but no single
document on the topic, hence I am proposing for one to be created,
making web2py more open to contributors, especially making it easier
for casual ones.

Some projects have a file on the top level directory with this info,
along with README, LICENSE, VERSION, etc., I don't think there is a
standard for that, some projects call it HACKING, some README.Hacking,
linux kernel is very complete in this regard and has a several files:
MAINTAINERS
REPORTING-BUGS
Documentation/BUG-HUNTING
Documentation/CodingStyle
Documentation/HOWTO
Documentation/ManagementStyle
Documentation/SecurityBugs
Documentation/SubmitChecklist
Documentation/SubmittingDrivers
Documentation/SubmittingPatches

Of course that would be an overkill for a project of this size but
taking a look into those files can provide a good insight of what I am
talking about, especially the HOWTO.

I think the first question this file should answer is "Where do I
start?". Without such a file, the first thing I did was looking at
web2py website, there is no "developers" section, but there is a
"Contributors" one, looking there there is a list of contributors and
an agreement to be signed. OK, even if I sign it, what's next? Not
much else on the section.

Going on with the exploration of the website, on the Documents section
there is nothing on this topic either. On the Download section there
is a clue, there is Developers column on the download where there are
links for two repositories, one on github and a mercurial one on
google code and a link to report bugs also on google code.

Hum, getting closer, I know where I can submit bug-reports at least.
Looking at the project page on google code there is nothing on the
Wiki or Home section either.

So I get two repos and some questions:
Should I use git or the mercurial one? Or it doesn't matter?
Do they get in sync? If so, how often?
Which repo/version/branch should I use to base patches on?
Where should I submit patches? Mailing list? Issues tracker? A
pull on github?
Where is the official trunk?
Is there a process of patch submission/review?
Is there any specific convention or style should I follow?


Do you guys think it would be valuable to have a file with this info?
I would certainly appreciate it as I hope in the future start to
contribute, it wouldn't need to be anything fancy, just a couple
paragraphs with directions for starters.

I took a quick look to see what the Django Project had on this and
they have quite a comprehensive documentation for developers, to the
point they have a dedicated domain for it, code.djangoproject.com,
with a lot of useful information. Some examples from there are worth
taking a look:

Django source-code repository, wiki and bug-report system
https://code.djangoproject.com/
Getting the code
Browsing the code online
Getting involved
Tickets
Little, easy improvements
"Easy Pickings" Tickets
How to report security issues.
DjangoDesign
Branches
Descriptions of major changes to the codebase
Under discussion
More Django resources

How to contribute to Django
https://docs.djangoproject.com/en/1.5/internals/contributing/
Advice for new contributors
First steps
Guidelines
FAQ
Writing code
Coding style
Unit tests
Submitting patches
Working with Git and GitHub


Fabiano.

-- 

--- 
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: You can chain @make_member_of decorator

2013-05-04 Thread Vinicius Assef
Nice. :-)

On Sat, May 4, 2013 at 12:16 AM, Massimo Di Pierro
 wrote:
> This is in trunk but instead of
>
> db.define_table('person',
> Field('name'),
> Field('gender'),
> Field('birthdate', 'date'))
>
> db.define_table('animal',
> Field('name'),
> Field('gender'),
> Field('birthdate', 'date'))
>
>
> # Bind the function to tables.
> # Note the use of "self".
> # Due to this decorator, we're "inside" the instance.
>
> @make_member_of(db.person, 'just_men')
> @make_member_of(db.animal, 'just_males')
> def get_just_gender_equals_m(self):
> return self._db(self.gender == 'm').select()
>
>
> # Use the function as a regular table method.
> db.person.just_men()
> db.animal.just_males()
>
> You instead do:
>
> @db.person.add_method.just_men
> @db.animal.add_method.just_males
> def get_just_gender_equals_m(self):
> return self._db(self.gender == 'm').select()
>
> db.person.just_men()
> db.animal.just_males()
>
>
> I really love this!
>
> On Friday, 3 May 2013 09:27:29 UTC-5, viniciusban wrote:
>>
>> To make generic query functions truly generic, now you can stack or
>> chain @make_member_of decorator.
>>
>> It's now a slice:
>>
>> http://www.web2pyslices.com/slice/show/1625/turn-a-function-into-a-table-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.
>
>

-- 

--- 
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] Developers/contributors guidelines?

2013-05-04 Thread Vinicius Assef
I like the idea.

On Sat, May 4, 2013 at 8:16 PM, Fabiano Engler  wrote:
> Hi all,
>
> I have looked for some information on how web2py is developed and
> maintained, I found some bits of info here and there but no single
> document on the topic, hence I am proposing for one to be created,
> making web2py more open to contributors, especially making it easier
> for casual ones.
>
> Some projects have a file on the top level directory with this info,
> along with README, LICENSE, VERSION, etc., I don't think there is a
> standard for that, some projects call it HACKING, some README.Hacking,
> linux kernel is very complete in this regard and has a several files:
> MAINTAINERS
> REPORTING-BUGS
> Documentation/BUG-HUNTING
> Documentation/CodingStyle
> Documentation/HOWTO
> Documentation/ManagementStyle
> Documentation/SecurityBugs
> Documentation/SubmitChecklist
> Documentation/SubmittingDrivers
> Documentation/SubmittingPatches
>
> Of course that would be an overkill for a project of this size but
> taking a look into those files can provide a good insight of what I am
> talking about, especially the HOWTO.
>
> I think the first question this file should answer is "Where do I
> start?". Without such a file, the first thing I did was looking at
> web2py website, there is no "developers" section, but there is a
> "Contributors" one, looking there there is a list of contributors and
> an agreement to be signed. OK, even if I sign it, what's next? Not
> much else on the section.
>
> Going on with the exploration of the website, on the Documents section
> there is nothing on this topic either. On the Download section there
> is a clue, there is Developers column on the download where there are
> links for two repositories, one on github and a mercurial one on
> google code and a link to report bugs also on google code.
>
> Hum, getting closer, I know where I can submit bug-reports at least.
> Looking at the project page on google code there is nothing on the
> Wiki or Home section either.
>
> So I get two repos and some questions:
> Should I use git or the mercurial one? Or it doesn't matter?
> Do they get in sync? If so, how often?
> Which repo/version/branch should I use to base patches on?
> Where should I submit patches? Mailing list? Issues tracker? A
> pull on github?
> Where is the official trunk?
> Is there a process of patch submission/review?
> Is there any specific convention or style should I follow?
>
>
> Do you guys think it would be valuable to have a file with this info?
> I would certainly appreciate it as I hope in the future start to
> contribute, it wouldn't need to be anything fancy, just a couple
> paragraphs with directions for starters.
>
> I took a quick look to see what the Django Project had on this and
> they have quite a comprehensive documentation for developers, to the
> point they have a dedicated domain for it, code.djangoproject.com,
> with a lot of useful information. Some examples from there are worth
> taking a look:
>
> Django source-code repository, wiki and bug-report system
> https://code.djangoproject.com/
> Getting the code
> Browsing the code online
> Getting involved
> Tickets
> Little, easy improvements
> "Easy Pickings" Tickets
> How to report security issues.
> DjangoDesign
> Branches
> Descriptions of major changes to the codebase
> Under discussion
> More Django resources
>
> How to contribute to Django
> https://docs.djangoproject.com/en/1.5/internals/contributing/
> Advice for new contributors
> First steps
> Guidelines
> FAQ
> Writing code
> Coding style
> Unit tests
> Submitting patches
> Working with Git and GitHub
>
>
> Fabiano.
>
> --
>
> ---
> 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] How to have an app-wise global var?

2013-05-04 Thread Fabiano Engler
How can I have app-wise global var in web2py?

As the models, controllers and views of web2py are executed for every
request, I cannot set a var on the top level scope of these files as
that assignment will be re-executed every request and reset the value.

Testing if the variable is already set in the top level scope and
setting it conditionally doesn't work either. Nor does it using
globals(), which I think is the same actually.


One way I found to do it is to set a var on the top level scope of a
custom module, but I don't know if my code can depend on this
behavior, as it seems this was changed when import_local() was
deprecated and it is undocumented.

Also I am not sure if this would be reliable depending on the
deployment method. For example, it obviously wouldn't work on a bare
cgi deploy, as the entire framework get executed every request. But I
consider bare cgi a corner case, for MVC we should always have a long
running process. What about other deploys, like wsgi on apache?

Another consideration is that it seems this approach wouldn't be
global per app but global per web2py instance -- this is not ideal but
could be circumvented by a name scoping mechanism, like using the app
name. (Even then, I my case it could be a security issue).

In some cases it would be possible to just store the value in a file
(like in the private folder) or in the database, but then it would be
persistent and not really a variable in the long running app.

The better alternative I found so far is to use cache.ram to store an
object and set time_expire=None. I played a bit with this option and
it seems to work just fine for my purposes.

Are there other/preferred way to have an app level variable in memory?

In case you are curious about my use case: I want to store an
encryption key in RAM memory only for as long as the app is running,
this key cannot go to persistent storage. When the app is started all
controllers that depend on this key will report an error until an
administrator logs into the app and manually enters a passphrase
(which should be stored only in administrator's brain), the app
derives the encryption key from the passphrase and keeps it into the
server's RAM memory as long as the app is running.


Fabiano.

-- 

--- 
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: Conditional Fields in Custom Forms

2013-05-04 Thread Fabiano
The problem seems to be your selector on jQuery. When using SQLForm it 
generates a table for you and you are hiding/showing a table 
row, jQuery('#no_table_band__row').

On your custom form, you don't have that row, hence it won't work, but you 
should have that field and the selector would be jQuery('#no_table_band'). 
This should work unless you are not outputting the field itself with 
=form.custom.widget.YOURFIELD (I don't see it in your view).

As others said, the best approach is to inspect the generated code.

Fabiano.

On Thursday, May 2, 2013 11:48:11 PM UTC-3, Josh Myers wrote:
>
> Hey Group,
>
> I am new to web2py and I am working to create a custom form from the 
> SQLForm.Factory with a conditional field built in.  
>
> I have two questions.
>
> 1.  Using a conditional field based on the checkbox, I can get it to work 
> if I don't use the custom form, but I can't get it to work with the custom 
> form.  Below is my code in the view.
>
> {{extend 'layout.html'}}
> {{=form.custom.begin}}
>  Set Model Options 
>  Model Name: {{=form.custom.widget.GAWR_Model_Name}} 
>  Sales Set: {{=form.custom.widget.Sales_Set}} 
>  Determine the Bandwidth 
> 
> jQuery(document).ready(function(){
>jQuery('#no_table_band__row').hide();
>jQuery('#no_table_CV').change(function(){
> if(jQuery('#no_table_CV').attr('checked'))
> jQuery('#no_table_band__row').show();
> else jQuery('#no_table_band__row').hide();});}); 
> 
>  {{=form.custom.widget.CV}} Manually Set the Bandwidth (default is 
> Cross Validation) 
> {{=form.custom.submit}}
> {{=form.custom.end}}
>
> 2.  I would like to be able to make a conditional field based on something 
> other than a checkbox, like the value of a set of radio buttons, multiple 
> checkboxes, or a standard select dropdown.  In the latter case, a User 
> would select a certain value in a dropdown and then another dropdown would 
> appear based on the value the User chose.  Can you point me toward any 
> resources on how to do that?
>
> Thank you.
>
> - Josh
>

-- 

--- 
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] copy a DAL row

2013-05-04 Thread lucas
hello one and all,

how do you copy a DAL row to a variable ensuring that the copy has a 
difference instance and memory address.  this way when the contents change 
in the copy, the original is left separate and unchanged.  good?

lucas

-- 

--- 
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] copy a DAL row

2013-05-04 Thread Vinicius Assef
You can save your row as a dict():
>>> row = db.mytable(id)
>>> saved_row = row.as_dict()




On Sat, May 4, 2013 at 11:54 PM, lucas  wrote:
> hello one and all,
>
> how do you copy a DAL row to a variable ensuring that the copy has a
> difference instance and memory address.  this way when the contents change
> in the copy, the original is left separate and unchanged.  good?
>
> lucas
>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

-- 

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




Re: [web2py] How to have an app-wise global var?

2013-05-04 Thread Vinicius Assef
Set your variable to session:
>>> session.my_var = "my_content"

http://web2py.com/books/default/chapter/29/03#Let's-count ;-)



On Sat, May 4, 2013 at 11:11 PM, Fabiano Engler  wrote:
> How can I have app-wise global var in web2py?
>
> As the models, controllers and views of web2py are executed for every
> request, I cannot set a var on the top level scope of these files as
> that assignment will be re-executed every request and reset the value.
>
> Testing if the variable is already set in the top level scope and
> setting it conditionally doesn't work either. Nor does it using
> globals(), which I think is the same actually.
>
>
> One way I found to do it is to set a var on the top level scope of a
> custom module, but I don't know if my code can depend on this
> behavior, as it seems this was changed when import_local() was
> deprecated and it is undocumented.
>
> Also I am not sure if this would be reliable depending on the
> deployment method. For example, it obviously wouldn't work on a bare
> cgi deploy, as the entire framework get executed every request. But I
> consider bare cgi a corner case, for MVC we should always have a long
> running process. What about other deploys, like wsgi on apache?
>
> Another consideration is that it seems this approach wouldn't be
> global per app but global per web2py instance -- this is not ideal but
> could be circumvented by a name scoping mechanism, like using the app
> name. (Even then, I my case it could be a security issue).
>
> In some cases it would be possible to just store the value in a file
> (like in the private folder) or in the database, but then it would be
> persistent and not really a variable in the long running app.
>
> The better alternative I found so far is to use cache.ram to store an
> object and set time_expire=None. I played a bit with this option and
> it seems to work just fine for my purposes.
>
> Are there other/preferred way to have an app level variable in memory?
>
> In case you are curious about my use case: I want to store an
> encryption key in RAM memory only for as long as the app is running,
> this key cannot go to persistent storage. When the app is started all
> controllers that depend on this key will report an error until an
> administrator logs into the app and manually enters a passphrase
> (which should be stored only in administrator's brain), the app
> derives the encryption key from the passphrase and keeps it into the
> server's RAM memory as long as the app is running.
>
>
> Fabiano.
>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups 
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

-- 

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




Re: [web2py] How to have an app-wise global var?

2013-05-04 Thread Fabiano
I can't use sessions because then the variables would be stored per session, 
not per app. I need all requests (hence all sessions) to share the same 
instance. Also it seems web2py stores sessions on disk, which is against my 
requirements.

Fabiano.

-- 

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