Re: [web2py] Any jquery gurus out there?

2012-07-24 Thread RKS
I will test both of the above comments. Sorry it took so long for me to get 
back, but I didn't realize anyone had responded. Thanks for the answers.





On Wednesday, July 11, 2012 5:58:19 PM UTC-5, demetrio wrote:
>
>
> I don't understand a lot the pourpose of this selector 
>
> > $(document.location.hash).removeClass("hidden"); 
> > 
>
> If the element has the id attr as the same hash you should use 
>
> > $("#"+document.location.hash).removeClass("hidden"); 
>
> Or if the hash is in the href attr you can use 
>
> > $('[href="'+document.location.hash+'"]').removeClass("hidden"); 
>
> In this case i don't know if you have to use the # becasue i think that it 
> is included in the href tag, maybe it can be 
>
> > $('[href="#'+document.location.hash+'"]').removeClass("hidden"); 
>
> Another thing you can do if nothing of this works is to use the command 
>
> console.log(document.location.hash); 
>
> To check if its really taking the hash value in IE


On Wednesday, July 11, 2012 5:58:19 PM UTC-5, demetrio wrote:
>
>
> I don't understand a lot the pourpose of this selector 
>
> > $(document.location.hash).removeClass("hidden"); 
> > 
>
> If the element has the id attr as the same hash you should use 
>
> > $("#"+document.location.hash).removeClass("hidden"); 
>
> Or if the hash is in the href attr you can use 
>
> > $('[href="'+document.location.hash+'"]').removeClass("hidden"); 
>
> In this case i don't know if you have to use the # becasue i think that it 
> is included in the href tag, maybe it can be 
>
> > $('[href="#'+document.location.hash+'"]').removeClass("hidden"); 
>
> Another thing you can do if nothing of this works is to use the command 
>
> console.log(document.location.hash); 
>
> To check if its really taking the hash value in IE

-- 





[web2py] Re: Any jquery gurus out there?

2012-07-24 Thread RKS
That is true. I have also run into that problem. At first, I thought it 
might be that too so I changed it and it still didn't work right. When I 
noticed I was sure that was it (or rather was hoping that was it.) I did 
also do a search and it seems that problem is not very-well documented 
either. Strange since almost everything I've ever run into someone else has 
seen it all before.





On Thursday, July 12, 2012 12:57:46 PM UTC-5, Derek wrote:
>
> You know, with IE, I have had problems if my "script" tags didn't have 
> "type='text/javascript".
>
> On Tuesday, July 10, 2012 3:54:14 PM UTC-7, RKS wrote:
>>
>> I know this is probably not the right place to ask, but I am using w2p 
>> and post here pretty frequently so I figured what the heck. I'm also in a 
>> rush and not finding out what I need on stackoverflow.
>>
>> I have some jquery and it works in every browser except any version of 
>> IE. If you happen to notice anything right off the bat that will cause this 
>> not to work, please let me know. I'm desperate. Thanks.
>>
>> https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js</a>
>> ">
>> 
>> $(function () {
>> // hide all the steps on document load
>> $("div.step").addClass("hidden");
>> // show the one step that is identified by the current hash 
>> (if any)
>> $(document.location.hash).removeClass("hidden");
>> $("a.reveal").click(function (event) {
>> var idToReveal = $(this).attr("href");
>> // store the ID to show in the URL for bookmarking
>> document.location.hash = idToReveal;
>> // hide every step that is currently visible
>> $("div.step").not(".hidden").addClass("hidden");
>> // reveal the next div (as identified by the current 
>> link's href)
>> $(idToReveal).removeClass("hidden");
>> // prevent the default click behavior (i.e. prevent 
>> navigation)
>> event.preventDefault();
>> });
>> });
>> 
>>
>> Quick recap, this hides divs and shows them via anchors on the page. It 
>> also saves the hash so on reload it opens to the current hash instead of 
>> going back to 1. Thanks
>>
>

-- 





Re: [web2py] Any jquery gurus out there?

2012-07-11 Thread RKS

>
> What is it that isn't working in IE?
>

I'm fairly certain the hash part just bunks it up but I have no way of 
confirming it. I've tried all the debugging tools I could find and either 
I'm too stupid to figure out how to get them to work or I'm too stupid to 
figure out what step I'm missing in the debugging process.

 

> Have you checked the Javascript console?


Yes. I've even followed similar tutorials as you've posted but no matter 
what I try everything remains greyed out. There is never an option to 
execute even after inserting breakpoints and trying to run. jsfiddle is 
completely inept when it comes to viewing the site in IE<9 so that's 
useless too. 


[web2py] Any jquery gurus out there?

2012-07-10 Thread RKS
I know this is probably not the right place to ask, but I am using w2p and 
post here pretty frequently so I figured what the heck. I'm also in a rush 
and not finding out what I need on stackoverflow.

I have some jquery and it works in every browser except any version of IE. 
If you happen to notice anything right off the bat that will cause this not 
to work, please let me know. I'm desperate. Thanks.

https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js";>

$(function () {
// hide all the steps on document load
$("div.step").addClass("hidden");
// show the one step that is identified by the current hash (if 
any)
$(document.location.hash).removeClass("hidden");
$("a.reveal").click(function (event) {
var idToReveal = $(this).attr("href");
// store the ID to show in the URL for bookmarking
document.location.hash = idToReveal;
// hide every step that is currently visible
$("div.step").not(".hidden").addClass("hidden");
// reveal the next div (as identified by the current link's 
href)
$(idToReveal).removeClass("hidden");
// prevent the default click behavior (i.e. prevent 
navigation)
event.preventDefault();
});
});


Quick recap, this hides divs and shows them via anchors on the page. It 
also saves the hash so on reload it opens to the current hash instead of 
going back to 1. Thanks


[web2py] Updated deplopyment docs?

2012-07-05 Thread RKS
Are there any updated deployment docs available? At work we run web2py no 
problems but we have our own servers. At home, for all my testing sites, I 
use shared hosting. Below is some correspondence I've had today with my 
shared host:

[After emailing them the link to the deployment recipes in the 
documentation:]

"We have looked at the page and unfortunately it doesn't look like it
>> will work well with our shared Web hosting service. In particular we
>> don't support mod_wsgi and you wouldn't be able to run the web2py
>> built-in web server and proxy off to it either, since you don't have
>> root access or the ability to run daemons (so the two installation
>> methods they discuss in detail won't work).
>>
>> In fact the whole page assumes that you are installing Web2py on a
>> dedicated or virtual private server rather than a shared Web hosting
>> server. So it's likely that there would be other problems as well."
>>
>
[After forwarding the section on mod_python:]

"Unfortunately, no -- we don't use mod_python, mod_wsgi, or any of the
>> other things mentioned on that page. In our experience,few shared
>> hosting providers use either mod_python or mod_wsgi now, which makes us
>> think that page is perhaps outdated, to be honest.
>>
>> We're very sorry about that. I wish we had a better answer! We had
>> several people here review what they suggest, though, and we're sure
>> that none of those options will work on our servers. It really does seem
>> like you probably need to use a Virtual Private Server or a dedicated
>> server to run that software."
>>
>
So are there any updated instructions on deployment? I'm really just 
looking to have a live testing bed where I can load w2p applications and 
view them from external services like browserlabs etc. Hence the need for 
it to be live. With this host I do have shell access but no sudo or Apache 
config permissions. They're running the latest apache and are already set 
up to support Django and run several django sites already, so I think w2p 
is certainly doable there.


[web2py] Re: Parsing python from db fields?

2012-06-28 Thread RKS
That's fine. I'm sorry for such a dumb mistake. Don't know why I did that. 
Here it is.


[web2py] Re: Sending message.html to single new user?

2012-06-27 Thread RKS
Ah, I see. Can't test now but I will in the morning. Thanks.

On Wednesday, June 27, 2012 7:30:14 PM UTC-5, Anthony wrote:
>
> mail.send(to=['form.vars.email'],subject='Your Registration 
>> Details',message=response.render('new_user.html'))
>>
>
> You have put form.vars.email in quotes, as if that is the literal email 
> address. Just do to=[form.vars.email].
>
> Anthony 
>


[web2py] Sending message.html to single new user?

2012-06-27 Thread RKS
In the book it mentions sending message.html to every person in the 
database. I know you know where it is already but for posterity 
sake...http://web2py.com/books/default/chapter/29/8.

There now seems to be a problem with my code as it only sends the first 
mail.send and not the other. I really would like to take the 
form.vars.email and send them message.html that is a template with their 
login info and how to login as well as some other form.vars I have in the 
form they fill out.

My controller:

def new_post():
form = SQLFORM(db.post)
if form.accepts(request, formname=None):
mail.send(to=['r...@rks.com'],subject='New Registration at 
RKS',message=', '.join('%s: %s' % (k, v) for (k, v) in 
request.vars.iteritems()))
mail.send(to=['form.vars.email'],subject='Your Registration 
Details',message=response.render('new_user.html'))
return DIV("Test")
elif form.errors:
return TABLE(*[TR(k, v) for k, v in form.errors.items()])

My view:


First Name *
Last Name *
Email *



It seems my default code does not recognize form.vars.email because I'm not 
defining it in the form inside the controller? That's the only thing I can 
think of there. Plus I realize now that I'm not going to get vars from one 
view in another or auth.user vars from a non-logged in user? Correct?


[web2py] Re: Is there a place to vote to add an id or class to user forms?

2012-06-27 Thread RKS
Don't want to be a prude but do you happen to have that URL handy?

On Wednesday, June 27, 2012 6:00:11 PM UTC-5, Massimo Di Pierro wrote:
>
> Make a proposal on googlecode issues
>
> On Wednesday, 27 June 2012 16:41:23 UTC-5, RKS wrote:
>>
>> I think it might be pretty simple just to add a class or id to the 
>> auth.user forms by default. It's unsemantic to have to wrap it in a div 
>> just to target those specific inputs or tedious to target them in the 
>> stylesheet by #auth_user_first_name__row input {} etc or by the 
>> #auth_user_first_name__label etc when I want every single one to look the 
>> same. Much easier to target #w2p_auth_login__form input etc.
>>
>

[web2py] Is there a place to vote to add an id or class to user forms?

2012-06-27 Thread RKS
I think it might be pretty simple just to add a class or id to the 
auth.user forms by default. It's unsemantic to have to wrap it in a div 
just to target those specific inputs or tedious to target them in the 
stylesheet by #auth_user_first_name__row input {} etc or by the 
#auth_user_first_name__label etc when I want every single one to look the 
same. Much easier to target #w2p_auth_login__form input etc.


[web2py] Re: Parsing python from db fields?

2012-06-27 Thread RKS
Unless you're very curious about this problem I wouldn't try too hard. I'm 
under a deadline so I just used an if statement to wrap the include file I 
need and referenced the specific pages inside the if.

Might not be the most elegant way to do things and certainly it falls into 
the workaround way of doing it, but for now it's what I'm going to do. 

Thanks, both of you, for all your help on this.


Re: [web2py] Re: Creating users on checkout?

2012-06-26 Thread RKS
Not to mention the redirect to user/profile I mentioned in another post. 
Trying to invoke auth.register() with a logged in user will force a 
redirect. Instead, I think it's best I just select the auth.users table and 
write directly to the database. But easier said than done.

On Monday, June 25, 2012 2:53:07 PM UTC-5, RKS wrote:
>
> Also, if you were to use the {{=*.custom.widget.email}} method you get 
> errors when a logged in user is using the form. The form tries to act like 
> a registration form instead of a checkout form. 
>
> If I use things in the inputs like {{=auth.user.first_name}} it works to 
> prefill values if users are logged in. But afaik it looks like setting the 
> values to the auth.users db manually after checkout is the only way to go. 
> I could be wrong thought since I'm not as good on web2py as many/most other 
> people here.
>

-- 





[web2py] Re: How does the auto-increment on field id work? I'd like to use the method in a table.

2012-06-26 Thread RKS
Perfect. I got the web2py Application cookboo eBook but you really need to 
write a book. I'd buy it. You help me more than anyone. Thanks a bundle.

-- 





[web2py] Re: Parsing python from db fields?

2012-06-26 Thread RKS
View source does not show anything below the content inside that XML. 

For example, I have a layout.html with the standard {{include}} {{ include 
footer.html}} etc.

The place where I have this XML element fall within the view that's 
extending this layout. So no matter what, there should be a footer at the 
very least. There's none. Even after the XML I have HTML within that view 
that no longer exists in source. The new source just ends after the content 
of blog.body like web2py no longer recognizes anything else.

That's why I added in the {{pass}} trying to force web2py to stop whatever 
it is doing to ignore the rest of the HTML.

There is no  since the data being called inside the blog.body is 
just a field from the db. I know I could have put a  in the field or 
in the included view it's calling but I double checked after reading your 
comment and there is none. All that html after the snippet is just like 
Keyser Soze.

-- 





[web2py] Re: Parsing python from db fields?

2012-06-26 Thread RKS
In that trial I was trying to end the python, thinking possibly it's 
affecting what follows. Deleting it does nothing. 

Sort of like {{if:}},{{else:}},{{pass}}. I was just trying to make it 
render that python and then stop.

On Tuesday, June 26, 2012 5:16:49 AM UTC-5, Cliff Kachinske wrote:
>
> What is the purpose of this line of code?
>
> {{pass}}
>
>
> What happens if you delete it?
>
> On Monday, June 25, 2012 2:17:32 PM UTC-4, RKS wrote:
>>
>> BTW, it's EVERYTHING in html after that snippet. It won't display the 
>> footer or anything.
>>
>

-- 





[web2py] How does the auto-increment on field id work? I'd like to use the method in a table.

2012-06-26 Thread RKS
I have some html:

{{for i, (product_id, qty, total_price, product, options) in 
enumerate(order):}}

-
+

I have a js function that takes min_pro_1 and plus_pro_1 and allows them to 
decrement of increment value_pro_1. So they're just buttons a user can 
click and the product quantity goes up and down. Well, the js I have needs 
each quantity field to have a unique id (imagine that) but my {{for i}} 
python just creates each item with the same id.  How do I increment these 
ids to ensure valid code and proper functioning of the js?

So item two would be:


-
+

And so on. The function I've got in my controller now is:

def increment(self,key,value=1):
self.locker.acquire()
try:
if key in self.storage:
value=self.storage[key][0]+value
self.storage[key]=(value)
except BaseException, e:
self.locker.release()
raise e
self.locker.release()
return value

And I figured I could do something like:

{{for i, (product_id, qty, total_price, product, options) in 
enumerate(order):}}

-
+

-- 





[web2py] Re: Redirecting to user/profile?

2012-06-25 Thread RKS
I actually just decided that I probably just need to manually add new 
values to db.auth.users. That way this is actually a non-issue and I won't 
even need to worry about it.

I think it may be harder since I don't know how to do that, especially with 
the checks on if auth.user or IS_IN_DB references but I can't see this 
working any other way for what I want to do. The end goal is to take a 
checkout form that will submit like normal to the payment gateway but at 
the same time register users if they don't have accounts, not register 
users if they're logged in or the email value exists already in the 
auth.user db.

The code I have already in the controller is:

def checkout_test():
order = []
balance = 0
for product_id, qty, option_ids in session.cart:
products = db(db.product.id == product_id).select()
if products:
product = products[0]
options = [db.option[id] for id in option_ids]
total_price = qty * (product.price + sum([option.price for 
option in options]))
order.append((product_id, qty, total_price, product, options))
balance += total_price
else:
pass
session.balance = balance
if form.accepts(request, formname=None):
#if not auth.user:
#if field.email IS_NOT_IN_DB:
#register email field in auth.users db
   # pass
#pass
mail.send(to=['r...@rks.com','customer_email'],subject='Test 
Success',message=', '.join('%s: %s' % (k, v) for (k, v) in 
request.vars.iteritems()))
return dict(order=order, merchant_id=session.paypal_id)
elif form.errors:
return TABLE(*[TR(k, v) for k, v in form.errors.items()])

Of course, you'll notice some invalid code in there that I have as 
placeholders for myself to logically symbolize what I need done. 

-- 





[web2py] Redirecting to user/profile?

2012-06-25 Thread RKS
I'm having some issues I don't fully understand. I've customized an 
auth.login using login_form.custom.widget.email etc in a controller. It 
works fine and logs in users like you would expect.

However, I have a view, checkout_test.html where I have included another 
form=auth.register() in the controller. By default, a logged in user who 
teis to access a page with auth.register() gets redirected to user/profile. 

How can I stop this behavior on at least this one view? The reason this is 
all here is that I'm extending the option to users on checkout to login or 
create an account on successful checkout. So I'm trying to expose all the 
auth.registration functions for non-logged in users. With the redirection, 
these functions are preventing any logged in user from ever checking out.

[SIDENOTE: I haven't been able to perfect my registering users on 
successful checkout just yet so I could end up not having to include any 
standard auth.register anything in this view once all is said and done.]

-- 





Re: [web2py] Re: Creating users on checkout?

2012-06-25 Thread RKS
Also, if you were to use the {{=*.custom.widget.email}} method you get 
errors when a logged in user is using the form. The form tries to act like 
a registration form instead of a checkout form. 

If I use things in the inputs like {{=auth.user.first_name}} it works to 
prefill values if users are logged in. But afaik it looks like setting the 
values to the auth.users db manually after checkout is the only way to go. 
I could be wrong thought since I'm not as good on web2py as many/most other 
people here.

-- 





Re: [web2py] Re: Creating users on checkout?

2012-06-25 Thread RKS
I see that there are auth.register() and auth.login(), I'm already using 
login_form=auth.login(), in the controller, but otherwise I'm not certain 
the checkoutform would be form=auth.register(). Maybe it can be, but is 
that the best practice? Or just creating a function that writes into the 
same auth.user db?


-- 





Re: [web2py] Parsing python from db fields?

2012-06-25 Thread RKS
Both of these solutions ended up working. Passing URL and using globals(). 
Just wanted to let you know and say thanks for helping.

-- 





[web2py] Re: Parsing python from db fields?

2012-06-25 Thread RKS
BTW, it's EVERYTHING in html after that snippet. It won't display the 
footer or anything.

-- 





[web2py] Re: Parsing python from db fields?

2012-06-25 Thread RKS
This all works, but I can't wrap my head around why everything after this 
snippet is no longer displayed. It does not even exist in the source. For 
example, my code is like this:


{{import os}}
{{from gluon.template import render}}
{{=XML(render(blog.body,path=os.path.join(request.folder, 
'views'), context=globals()))}}
{{pass}}

 

NEW USER?



CURRENT USER?
{{=blog_form}}




Everything from the inserted comment () will not exist any more 
after this. Go back to simple {{=XML(blog.body)}} and everything after it 
displays fine. I've tried adding a pass, no pass, two passes, etc. But it 
still appears from that point web2py is not recognizing regular html 
anymore. Nothing after that will display at all.

-- 





[web2py] Re: Creating users on checkout?

2012-06-25 Thread RKS
Not so easy?

-- 





[web2py] Re: Parsing python from db fields?

2012-06-22 Thread RKS
Okay, so that works on everything except href="{{=URL('something')}} it 
returns the error "URL is not defined." I'm going to try the other anchor 
method available and see if that works.

The {{=blog.title}} and {{include 'postviews3.html'}} works fine with this 
solution.

-- 





[web2py] Creating users on checkout?

2012-06-21 Thread RKS
I'm using the standard users/login and users/register for normal 
operations; however, I want to include these functions in a checkout 
function. For the login, I've read up on auth.login but for the 
registration portion I have no idea where to look.

I have defined checkout.html with a return(form=auth.login(), order=order). 
I have created a form in the view with an action {{=auth.login}}. It seems 
this is what I need? My one question (since this is in dev I can't test the 
checkout functionality yet) is whether this form is going to interfere with 
the second form in the view that submits the order. Since both actions are 
different, I don't think so but a) I don't even know if my login form 
action is correct and b) I don't know if the return(form=auth.login) is 
going to hijack the second form and treat it like a login form as well.

My plan for the second part(registration), is just to check if the user is 
logged in and if not create a new user based on the information given. I'm 
already asking for all the information I need to create an account, I just 
want the form to submit the order, and then create a user at the same time. 
Anything out there that can help? Maybe some documentation or tutorial or 
something? 

Also, can someone point me to the standard fields for auth.users? I would 
like to auto-insert values like {{=auth.email}} or {{=auth.firstname}} in 
my fields for logged in users.

-- 





[web2py] Re: Parsing python from db fields?

2012-06-21 Thread RKS
Traceback:

Traceback (most recent call last):
  File "gluon/restricted.py", line 205, in restricted
  File 
"/Applications/web2py.app/Contents/Resources/applications/dev/views/default/blogs.html",
 
line 132, in 
  File "gluon/template.py", line 919, in render
  File "gluon/template.py", line 320, in __init__
  File "gluon/template.py", line 720, in parse
  File "gluon/template.py", line 454, in include
  File "gluon/template.py", line 438, in _get_file_text
  File "posixpath.pyc", line 62, in join
AttributeError: 'NoneType' object has no attribute 'endswith'


DB content:

(I'm trimming the HTML since it's a rather large post but if you think you 
need the rest of it I will post it too. However, leaving the ommitted HTML 
in and taking out the python resolves the problem so I don't think the HTML 
is to blame.)



NEW USER?



CURRENT USER?
{{=blog_form}}



{{include 'default/postsviews3.html'}}





The postsviews3.html is just a standard HTML. The blog_form is defined in 
the controller and works outside of this scenario. Of course, the URLs also 
work outside of this instance.

-- 





[web2py] Re: Parsing python from db fields?

2012-06-21 Thread RKS
Hmm. I'm going to try and play with this a little tonight and report back 
tomorrow but on first try both these solutions return an error 
 'NoneType' object has no attribute 
'endswith'


Don't know what that is but I'm digging in right now to find out.

-- 





[web2py] Re: Parsing python from db fields?

2012-06-21 Thread RKS
Yes. Inside the actual field I use HTML and python. If I use 
{{=XML(blog.body)}} then I can insert all the HTML I want inside that field 
from the db administration. Very helpful.

But now I want to be able to insert {{=blog.title}} inside the blog.body 
field and when it renders int he view I want to execute {{=blog.title}}. 
Also, I have an HTML view that aggregates all of the blogs. So I want to 
include this inside the field blog.body.

So with your example are you saying when I use {{=XML(blog.body)}} I should 
use {{=eval(blog.body)}} or are you telling me to put eval or exec inside 
the {{=blog.title}} that I am calling inside the field? So would it be 
{{=exec(blog.body)}} or {{=exec(blog.title)}} inside blog.body?

Sorry, this all seems confusing. Thanks.

-- 





Re: [web2py] consider adding a div around error message

2012-06-21 Thread RKS
An inline-block has auto-width and will stretch to fit the error message. I 
don't see why you need the extra div wrapper. You could also change your 
error message to be inline.

On Friday, March 2, 2012 11:00:11 AM UTC-6, Richard wrote:
>
> Hello,
>
> Could we consider this change :
>
> Wrapping error div inside an other div?
>
> Reason :
>
> Allow auto width of error box base on length of error message.
>
> Try this with chrome dev tool on a triggered validator page :
>
>id="myfield__error" style="display: inline-block; ">field can't be 
> empty  
>
> I think it will work every where 3cols 2cols and divs... I try it with 3 
> cols and divs.
>
> Thanks
>
> Richard
>

-- 





[web2py] Parsing python from db fields?

2012-06-21 Thread RKS
I have a table defined with some old fashioned fields. When printing the 
fields in a view I use {{=XML(field.name)}} and so far this works great for 
all the HTML I've been putting in there all this time. 

Now I've come to a situation where I'm trying to print some python from a 
field. Might be recursive, but if I have {{=field.name}} it prints that out 
directly instead of recognizing that it's a call and should go look for the 
field referenced. The reason I'm doing it this way is that my view is 
defined for all items of that type. One item has some differences and it 
should include another HTML file such as {{include "html.html"}} but that 
just prints instead of trying to find that html and include it.

Hopefully this wasn't so confusing.

So instead of {{=XML(field.name)}} when printing this particular field, 
what should this be in order to parse the python and html inside? Thanks.

-- 





[web2py] Re: Changing images and CSS with language preferences

2012-06-13 Thread RKS
Thanks. Works great. I never thought about translating my CSS attributes. 
For anyone coming in the future a quick example of what I've done with 
Massimo's suggestion is add for image swapping:

{{if T.accepted_language in('en','en-us'):}}

{{else:}}

{{pass}}

and for the css attributes you can just add the T function inside a class 
or id like:

Some text

And then in es.py I just changed the definition of paragraph to 
paragraph_es or you can keep paragraph and add an additional class like 
paragraph spanish. And then make sure you add styles to your CSS to account 
for these new styles.

Hopefully that's exactly what you were telling me to do, Massimo, cause it 
works. Sorry to post all this but I like to be thorough with my solutions 
so no one has to ask later.


Thanks again.


[web2py] Changing images and CSS with language preferences

2012-06-13 Thread RKS
The old way I was doing things (because I hadn't had time to explore how 
w2p was handling T) was creating multiple views based on languages with 
anchors pointed at these different views. Easy enough since I only had like 
6 views to translate into one other language.

But now that I want to do things right, and for the simple fact that some 
things are given to me programmatically instead of in the HTML, I changed 
everything over to T strings. It works great and it's simple. 

The problem I'm having now is that some images contain text that I need to 
translate and serve the user that image instead of the original. The other 
problem is things like dynamically changing the CSS. In Spanish there's a 
5:1 ratio for words to say the same thing and several times in my design 
just a straight translation will break the layout. When I was doing 
multiple views, I could add different classes and change the CSS that way, 
now I can't seem to figure that out.

So how would I do that? I'm sure there has to be some 'if language=es' type 
function I could put in there I just have more design sense than w2p sense. 
Thanks.


[web2py] Trouble running from source

2012-05-25 Thread RKS
Docs say run python2.7 web2py.py in the terminal and all I can get is the 
error:

/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python:
 
can't open file 'web2py.py'

Maybe I put it in the wrong place where it can't find it?


[web2py] Redirecting to a mobile website?

2012-05-23 Thread RKS
What is the best way to redirect uses to the mobile version of your site? 
I.e. redirecting to http://m.yoursite.com when it detects a mobile viewport?
I tried to do this the normal way that I redirect in other places but I 
keep getting invalid errors. We're just using js to detect the browser and 
then we can collect that data in w2p and redirect from there, correct?


[web2py] Re: Easy question, inserting user input fields into an email message

2012-05-22 Thread RKS
Thanks a lot. This solved my problem.


[web2py] Re: Easy question, inserting user input fields into an email message

2012-05-22 Thread RKS
That was my latest and yes, it does result in an error. The original was:

def new_post():
form = SQLFORM(db.post)
if form.accepts(request, formname=None):
mail.send(to=['s...@distrobeef.com'],subject='DistroBeef Retailer 
Contact',message='Test')
return DIV("Thank you for contacting us! We have received your 
information and will contact you shortly.")
elif form.errors:
return TABLE(*[TR(k, v) for k, v in form.errors.items()])

This works and I get test as a message. Next try was:

def new_post():
form = SQLFORM(db.post)
if form.accepts(request, formname=None):
mail.send(to=['s...@distrobeef.com'],subject='DistroBeef Retailer 
Contact',message='request.vars.
>
>
> distributor,request.vars.dba,request.vars.contactnum,request.vars.fax,request.vars.location,request.vars.locationtwo,request.vars.city,request.vars.state,request.vars.zip,
> request.vars.name,request.vars.contact,request.vars.email

')
return DIV("Thank you for contacting us! We have received your 
information and will contact you shortly.")
elif form.errors:
return TABLE(*[TR(k, v) for k, v in form.errors.items()])

And no luck. It just prints that verbatim. I tried quoted, unquoted, 
bracketed and ended up on the version I posted in the first comment. 

The goal is just to return the values of the fields the user typed. Nothing 
fancy. Just a boring old list of items.


[web2py] Easy question, inserting user input fields into an email message

2012-05-22 Thread RKS
So I got the mail function working correctly but now I can't get it to send 
me the fields from the form. The form is standard HTML with ids on all the 
inputs. In the controller I have:

def new_post_two():
form = SQLFORM(db.post)
if form.accepts(request, formname=None):

message=%(request.vars.distributor,request.vars.dba,request.vars.contactnum,request.vars.fax,request.vars.location,request.vars.locationtwo,request.vars.city,request.vars.state,request.vars.zip,request.vars.name,request.vars.contact,request.vars.email)
mail.send(to=['s...@distrobeef.com'],subject='DistroBeef Dealer 
Contact',message=message)
return DIV("Thank you for contacting us! We have received your 
information and will contact you shortly.")
elif form.errors:
return TABLE(*[TR(k, v) for k, v in form.errors.items()])   

What am I doing wrong here? (And this is just the latest version, I've 
tried a bunch of different things with the syntax and message part but 
obviously not the right combo.) Thanks.



[web2py] Mimicking HTML5 pattern attribute for inputs

2012-04-11 Thread RKS
I'm looking to validate all of my forms with HTML5 and the pattern 
attribute, but as always, nothing is perfect on the internet and I still 
need a backup to catch those users who do not use HTML5 friendly browsers.

I'm having trouble finding exact representations of the regular expressions 
in the handbook so if you know, I'd appreciate some help. I have written 
the code in two ways, the HTML way and the HTML helper way (see below) and 
the HTML5 works and validates in modern browsers except IE as expected but 
I can't translate them to python.

An example, you will see below, is the expression 
pattern="[A-F0-9]{11}|[A-F0-9]{14}"
This effectively forces an input to only contain uppercase letters of A-F 
and numbers 0-9. It also ensures the length is exactly 11 characters or 14. 
So how would I use this in web2py? IS_LENGTH seems to accept only a range 
from my tests and so far I've only found IS_ALPHANUMERIC to control what 
characters are accepted.

Please seem the form below:

HTML:


MSIE/ESN *


Zip Code *






   * denotes a required field.




HTML Helpers:

form=FORM(LABEL('MEID/ESN 
',(SPAN('*'))),INPUT(_name='meid',_pattern="[A-F0-9]{11}|[A-F0-9]{14}",_placeholder='MEID/ESN',_required='required',_title="The
 
MEID/ESN number only contains 11 or 13 characters, the letters A-F, and the 
numbers 0-9.",requires=[IS_LENGTH(11|14),IS_NOT_EMPTY()], 
_onblur="this.checkValidity();"),BR(),LABEL('ZIP CODE 
',(SPAN('*'))),INPUT(_name='zip',_type='number',_pattern="[0-9]{5}",_placeholder='Zip
 
Code',_required='required',_title="We only required the five character zip 
code.",requires=IS_NOT_EMPTY()),BR(),BR(),BR(),BR(),INPUT(_type='button',_name='cancel',_value='Cancel',_onclick="history.go(-1);return
 
true;"),INPUT(_type='submit',_name='submit',_value='Activate'),_method='post',_id='activate_form')
if form.accepts(request,session):
response.flash = 'Form accepted'
 #   redirect(URL('next'))
elif form.errors:
response.flash = 'Form has errors'
return dict(form=form)



Thanks.


[web2py] Re: New member and new to web2py and need some clarification about file paths.

2012-02-20 Thread RKS
Thanks guys.

@Massimo

The 

[web2py] New member and new to web2py and need some clarification about file paths.

2012-02-20 Thread RKS
Hello. Coming over from the php world and I started a new job where we
use web2py and python. I'm trying to wrap my head around how it's
handling the paths to pages I create and I can't find my answers in
the docs. Probably I'm just missing it but I can't seem to figure it
out.

I've already created the layout.html and all the page.html files
located in views/default/page.html. I added


def page():
return dict()


in default.py. Now I'm trying various methods of adding anchors into
my html and everything returns an invalid error. For example, , ,  and
nothing seems to work. I'm running it from 127.1.1.8000. I'm at home
so I don't have my specific code here.

I'm actually the designer so I'm running the web2py OSX Lion app while
the developers are running Ubuntu and I've noticed a couple of things
are different based on that. Perhaps the way they were doing it needs
to be changed for the web2py app? Already some things that work in
Linux had to be changed to work on my Mac.

Also, what is the correct method to reference css and  images
that are located in the static/images directory?

Thanks and I look forward to meeting more python developers and
getting to know web2py a bit more. I'm coming over from a background
in php, asp, and vb. I hate asp and vb and was forced into it where I
used to work and so I'm super excited to be working with python now
instead. The only good thing I took from asp was the C and that helps
with iOS so it wasn't all bad but...

I'll shut up now. Thanks for your help.