Hi,
I am new to Google App Engine,
I have this entites User class -
user_id - integer
user_name - string
password - string
I want to do auto increment for the user_id,How I can do this?
hi,
I have a dict
val_dict - {'val1': 'abcd', 'val': '1234', 'val3': '1234.00', 'val4': '1abcd 2gfff'}
All the values to my keys are string.
So my question is how to find out type for my values in the dict.
I mean if i say`int(val_dict['val1']) will give me error.
Basically what I am trying to do is find out if the string is actual string or int or float.`
if int( val_dict['val1'):
dosomething
else if float(val_dict['val1']):
dosomething
thanks
I'm currently putting the finishing touches to an application for a client, this application sends daily emails to subscribers, is it possible to add custom headers to the email so that certain variables can be tracked, like day number (X-Day-Number) etc...
After installing the BitTorrent-bencode package, either via easy_install BitTorrent-bencode or pip install BitTorrent-bencode, or by downloading the tarball and installing that via easy_install $tarball, I discover that /usr/local/lib/python2.6/dist-packages/BitTorrent_bencode-5.0.8-py2.6.egg/ contains EGG-INFO/ and test/ directories. Although both of these subdirectories contain files, there are no files in the BitTorr* directory itself. The tarball does contain bencode.py, which is meant to be the actual source for this package, but it's not installed by either of those utils.
I'm pretty new to all of this so I'm not sure if this is a problem with the package or with what I'm doing. The package was packaged a while ago (2007), so perhaps it's using some deprecated configuration aspect that I need to supply a command-line flag for.
I'm more interested in learning what's wrong with either the package or my procedures than in getting this particular package installed; there is another package called hunnyb that seems to do a decent enough job of decoding bencoded data. Mostly I'd like to know how to deal with such problems in other packages.
Hi,
Trying to execute shell command in background using pythons commands module
>>>import commands
>>>output = commands.getstatusoutput("find / > tmp.txt &")
sh: Syntax error: ";" unexpected
Can anyone explain what is wrong with the syntax ? How should it be executed then ?
Tazim.
Lets say I have an application with a structure such as:
System
set date
set name
set something
Other
set death ray target
calibrate
and I want to have "back" and "next" buttons on a page. The catch is, if you're going in via the "wizard", I want the nav path to be something like "set name" - "set death ray target" - "set name". If you go via the Advanced options menu, I want to just iterate options... "set date" - "set name" - "set something" - "set death ray target" - calibrate.
So far, I'm thinking I have to use different URIs, but that's that. Any ideia how this could be done?
Thanks.
THE TASK:
I am in the process of migrating a DB from MS Access to Maximizer. In order to do this I must take 64 tables in MS ACCESS and merge them into one. The output must be in the form of a TAB or CSV file. Which will then be imported into Maximizer.
THE PROBLEM:
Access is unable to perform a query that is so complex it seems, as it crashes any time I run the query.
ALTERNATIVES:
I have thought about a few alternatives, and would like to do the least time-consuming one, out of these, while also taking advantage of any opportunities to learn something new.
Export each table into CSVs and import into SQLight and then make a query with it to do the same as what ACCESS fails to do (merge 64 tables).
Export each table into CSVs and write a script to access each one and merge the CSVs into a single CSV.
Somehow connect to the MS ACCESS DB (API), and write a script to pull data from each table and merge them into a CSV file.
QUESTION:
What do you recommend?
class sss(webapp.RequestHandler):
def get(self):
url = "http://www.google.com/"
result = urlfetch.fetch(url)
if result.status_code == 200:
self.response.out.write(result.content)
and this view show :
when i change code to this:
if result.status_code == 200:
self.response.out.write(result.content.decode('utf-8').encode('gb2312'))
it show :
so ,what i should do ?
thanks
Hi,
I use the backend solution from django. I just want to get a username from the cookie or the session_key to get to know the user. How I can do it?
from django.contrib.auth.models import User
from django.contrib.sessions.models import Session
def start(request, template_name="registration/my_account.html"):
user_id = request.session.get('session_key')
if user_id:
name = request.user.username
return render_to_response(template_name, locals())
else:
return render_to_response('account/noauth.html')
Only else is coming up. What am I doing wrong?
Am I right then that authenticated means he is logged in?
-- Okay this I got!
Firstly, if you have some clarification to a question, update the question, don't post an answer or (even worse) another question, as you have done. Secondly, if the user is logged out, by definition he doesn't have a username.
I mean the advantage of Cookies is to identify a user again. I just want to place his name on the webpage. Even if he is logged out. Or isnt't it possible?
Is it possible to pickle an object from a class with slots, when this object references itself through one of its attributes? Here is a simple example:
import weakref
import pickle
class my_class(object):
__slots__ = ('an_int', 'ref_to_self', '__weakref__')
def __init__(self):
self.an_int = 42
self.ref_to_self = weakref.WeakKeyDictionary({self: 1})
# __getstate__ and __setstate__ not defined: how should this be done?
if __name__ == '__main__':
obj = my_class()
# How to make the following work?
obj_pickled = pickle.dumps(obj)
obj_unpickled = pickle.loads(obj_pickled)
# Self-references should be kept:
print "OK?", obj_unpickled == obj_unpickled.ref_to_self.keys()[0]
hello
is there any way to get the selected item in a qmenu ?
i want to bind all items in that list to one function and get the item once user click it .
i've been looking for a way to get the item's label or index for 3 days , but couldn't find it .
any ideas ?
thanks in advance
How can i write a program in php to get the domain information of an existing domain or a domain name is already taken..?? like informations using php?
I'm using Django's templating on appengine, and am having a problem whereby a class I'm importing from another package is not correctly being made available to the template context.
Broadly speaking, this is the code. The prop1 is not available in the template in the first example below, but is in the second. MyClass is identical in both cases.
This does not work:
from module import MyClass
context = MyClass()
self.response.out.write(template.render(path, context))
This does:
class MyClass(object):
def __init__(self):
self.prop1 = "prop1"
context = MyClass()
self.response.out.write(template.render(path, context))
If I log the context in the above code I get:
<module.MyClass object at 0x107b1e450>
when it's imported, and:
<__main__.MyClass object at 0x103759390>
when it's defined in the same file.
Any clues as to what might cause this kind of behaviour?
The urlconf and view is as follows:
url(r'^register/$',
register,
{ 'backend': 'registration.backends.default.DefaultBackend' },
name='registration_register'),
def register(request, backend, success_url=None, form_class=None,
disallowed_url='registration_disallowed',
template_name='registration/registration_form.html',
extra_context=None):
What i want to do is redirect users to the register page and specify a success_url. I tried reverse('registration.views.register', kwargs={'success_url':'/test/' }) but that doesn't seem to work. I've been trying for hours and can't get my mind around getting it right. Thanks
>>> float(1)
1.0
>>> float(1) / 10
0.10000000000000001
>>> 4 + (float(1) / 10)
4.0999999999999996
4 + (float(1) / 10) is expected to be 4.10000000000000001
Is this a kind of bug?
I'm writing to many files in a threaded app and I'm creating one handler per file. I have HandlerFactory class that manages the distribution of these handlers. What I'd like to do is that
thread A requests and gets foo.txt's file handle from the HandlerFactory class
thread B requests foo.txt's file handler
handler class recognizes that this file handle has been checked out
handler class puts thread A to sleep
thread B closes file handle using a wrapper method from HandlerFactory
HandlerFactory notifies sleeping threads
thread B wakes and successfully gets foo.txt's file handle
This is what I have so far,
def get_handler(self, file_path, type):
self.lock.acquire()
if file_path not in self.handlers:
self.handlers[file_path] = open(file_path, type)
elif not self.handlers[file_path].closed:
time.sleep(1)
self.lock.release()
return self.handlers[file_path][type]
I believe this covers the sleeping and handler retrieval successfully, but I am unsure how to wake up all threads, or even better wake up a specific thread.
Hello,
I have been trying to add some check boxes in a pylons mako. However I don't know how to get their values in the controller. It seems that it can only get the first value of the check boxes. I tried using form encode but i got several errors. Is there an easier way to do this?
Thanks
Cant we send a dictionary variable when using HttpResponseRedirect
render_to_response('edited/display.html',context_instance=RequestContext(request,{'newlist': newlist}))
//How can the dictionary and the request sent back again
//sumthing like this
return HttpResponseRedirect('edited/display.html',context_instance=RequestContext(request,{'newlist': newlist}))
info = {'phone_number': '123456', 'personal_detail': {'foo':foo, 'bar':bar}, 'is_active': 1, 'document_detail': {'baz':baz, 'saz':saz}, 'is_admin': 1, 'email': '[email protected]'}
return HttpResponse(simplejson.dumps({'success':'True', 'result':info}), mimetype='application/javascript')
if(data["success"] === "True") {
alert(data[**here I want to display personal_detail and document_details**]);
}
How can I do this?
Several times (even several in a row) I've been bitten by the defaultdict bug.
d = defaultdict(list)
...
try:
v = d["key"]
except KeyError:
print "Sorry, no dice!"
For those who have been bitten too, the problem is evident: when d has no key 'key', the v = d["key"] magically creates an empty list and assigns it to both d["key"] and v instead of raising an exception. Which can be quite a pain to track down if d comes from some module whose details one doesn't remember very well.
I'm looking for a way to take the sting out of this bug. For me, the best solution would be to somehow disable a defaultdict's magic before returning it to the client.
i have a function which is a class method, and i want to test a attribute of the class which may or may not be None, but will exist always.
class classA():
def __init__(self, var1, var2 = None):
self.attribute1 = var1
self.attribute2 = var2
@classmethod
def func(self,x):
if self.attribute2 is None:
do something
i get the error
AttributeError: class classA has no attribute 'attributeB'
when i access the attribute like i showed but if on command line i can see it works,
x = classA()
x.attributeB is None
True
so the test works.
if i remove the @classmethod decorator from func, the problem disapears.
if i leave the @classmethod decorator, it only seems to affect variables which are supplied default values in the super-class's constructor.
whats going on in the above code?