i want to find a webapp framework for validation user , store user,
and has ajax Effect of jquery ,
so ,did you know this simply framework ?
thanks
like this page : http: //digu.com/reg
my model is :
class MyUser(db.Model):
user = db.UserProperty()
password = db.StringProperty(default=UNUSABLE_PASSWORD)
email = db.StringProperty()
nickname = db.StringProperty(indexed=False)
and my method which want to get all username is :
s=[]
a=MyUser.all().fetch(10000)
for i in a:
s.append(i.username)
and the error is :
AttributeError: 'MyUser' object has no attribute 'username'
so how can i get all 'username',
which is the simplest way .
thanks
If I want to split a list of words separated by a delimiter character, I can use
>>> 'abc,foo,bar'.split(',')
['abc', 'foo', 'bar']
But how to easily and quickly do the same thing if I also want to handle quoted-strings which can contain the delimiter character ?
In: 'abc,"a string, with a comma","another, one"'
Out: ['abc', 'a string, with a comma', 'another, one']
Related question: How can i parse a comma delimited string into a list (caveat)?
MYMESSAGE = "<div>Hello</div><p></p>Hello"
send_mail("testing",MYMESSAGE,"[email protected]",['[email protected]'],fail_silently=False)
However, this message doesn't get the HTML mime type when it is sent. In my outlook, I see the code...
I am trying to return the duration of the video but am having trouble.
#YOUTUBE FEED
#download the file:
file = urllib2.urlopen('http://gdata.youtube.com/feeds/api/videos/2s0vk2wEMtA')
#convert to string:
data = file.read()
#close file because we dont need it anymore:
file.close()
#entire feed
root = etree.fromstring(data)
for entry in root:
for item in entry:
print item
When I print item, I see as the last element:
Element '{http://gdata.youtube.com/schemas/2007}duration' at 0x10c4fb7d0
But I don't know how to get the value from this. Any advice?
I have two classes, Tag and Hardware, defined with a simple parent-child relationship (see the full definition at the end).
Now I want to filter a query on Tag using the version field in Hardware through an attribute_mapped_collection, eg:
def get_tags(order_code=None, hardware_filters=None):
session = Session()
query = session.query(Tag)
if order_code:
query = query.filter(Tag.order_code == order_code)
if hardware_filters:
for k, v in hardware_filters.iteritems():
query = query.filter(getattr(Tag.hardware, k).version == v)
return query.all()
But I get:
AttributeError: Neither 'InstrumentedAttribute' object nor 'Comparator' object associated with Tag.hardware has an attribute 'baseband
The same thing happens if I strip it back by hard-coding the attribute, eg:
query.filter(Tag.hardware.baseband.version == v)
I can do it this way:
query = query.filter(Tag.hardware.any(artefact=k, version=v))
But why can't I filter directly through the attribute?
Class definitions
class Tag(Base):
__tablename__ = 'tag'
tag_id = Column(Integer, primary_key=True)
order_code = Column(String, nullable=False)
version = Column(String, nullable=False)
status = Column(String, nullable=False)
comments = Column(String)
hardware = relationship(
"Hardware",
backref="tag",
collection_class=attribute_mapped_collection('artefact'),
)
__table_args__ = (
UniqueConstraint('order_code', 'version'),
)
class Hardware(Base):
__tablename__ = 'hardware'
hardware_id = Column(Integer, primary_key=True)
tag_id = Column(String, ForeignKey('tag.tag_id'))
product_id = Column(String, nullable=True)
artefact = Column(String, nullable=False)
version = Column(String, nullable=False)
I have around 20 functions (is_func1, is_fucn2, is_func3...) returning boolean
I assume there is only one function which returns true and I want that!
I am doing:
if is_func1(param1, param2):
# I pass 1 to following
abc(1) # I pass 1
some_list.append(1)
elif is_func2(param1, param2):
# I pass 2 to following
abc(2) # I pass 1
some_list.append(2)
...
.
.
elif is_func20(param1, param2):
...
Please note: param1 and param2 are different for each, abc and some_list take parameters depending on the function.
The code looks big and there is repetition in calling abc and some_list, I can pull this login in a function! but is there any other cleaner solution?
I can think of putting functions in a data structure and loop to call them.
i have a directory with around 1000 files....i want to run a same code for each of these file...
my code requires the file name to be inputted.
i have written code to copy the information of one into other in other format...
please suggest a method to copy all 1000 files one by one without need to change the file name every time
and i have a field serial_num which need to be continous i.e if 1st file has upto 30 then while coping other file it should continue from 30not from 0 again
require suggestion please
thanks..
I have the following models in my Django app. How can I from the Team model find all the User objects who have accepted as True in the Membership model? I know I need to use Team.objects.filter(), but I'm not sure how to check the value of the accepted field.
from django.contrib.auth.models import User
class Team(models.Model):
members = models.ManyToManyField(User, through="Membership")
class Membership(models.Model):
user = models.ForeignKey(User)
team = models.ForeignKey(Team)
accepted = models.BooleanField(default=False)
If I have an entity derived from db.Expando I can write Dynamic property by just assigning a value to a new property, e.g. "y" in this example:
class MyEntity(db.Expando):
x = db.IntegerProperty()
my_entity = MyEntity(x=1)
my_entity.y = 2
But suppose I have the name of the dynamic property in a variable... how can I (1) read and write to it, and (2) check if the Dynamic variable exists in the entity's instance? e.g.
class MyEntity(db.Expando):
x = db.IntegerProperty()
my_entity = MyEntity(x=1)
# choose a var name:
var_name = "z"
# assign a value to the Dynamic variable whose name is in var_name:
my_entity.property_by_name[var_name] = 2
# also, check if such a property esists
if my_entity.property_exists(var_name):
# read the value of the Dynamic property whose name is in var_name
print my_entity.property_by_name[var_name]
Thanks...
Hey,
I'm running a function which evaluates commands passed in using stdin and another function which runs a bunch of jobs. I need to make the latter function sleep at regular intervals but that seems to be blocking the stdin. Any advice on how to resolve this would be appreciated.
The source code for the functions is
def runJobs(comps, jobQueue, numRunning, limit, lock):
while len(jobQueue) >= 0:
print(len(jobQueue));
if len(jobQueue) > 0:
comp, tasks = find_computer(comps, 0);
#do something
time.sleep(5);
def manageStdin():
print "Global Stdin Begins Now"
for line in fileinput.input():
try:
print(eval(line));
except Exception, e:
print e;
--Thanks
I want get the details of the wave such as its frames into a array of integers.
Using fname.getframes we can ge the properties of the frame and save in list or anything for writing into another wav or anything,but fname.getframes gives information not in integers some thing like a "/xt/x4/0w' etc..
But i want them in integer so that would be helpful for manupation and smoothening join of 2 wav files
Currently I have a website on the Google App Engine written in Google's webapp framework. What I want to know is what are the benefits of converting my app to run with django? And what are the downsides? Also how did you guys code your GAE apps? Did you use webapp or django? Or did you go an entirely different route and use the Java api?
Thanks
Using the pysnmp framework i get some values doing a snmp walk. Unfortunately for the oid
1.3.6.1.21.69.1.5.8.1.2 (DOCS-CABLE-DEVICE-MIB)
i get a weird result which i cant correctly print here since it contains ascii chars like BEL ACK
When doing a repr i get:
OctetString('\x07\xd8\t\x17\x03\x184\x00')
But the output should look like:
2008-9-23,3:24:52.0
the format is called "DateAndTime". How can i translate the OctetString output to a "human readable" date/time ?
Hi,
I am new to numpy. Am wonder is there a way to do lookup of two ndarray of different shapes?
for example, i have 2 ndarrays as below:
X = array([[0, 3, 6],
[3, 3, 3],
[6, 0, 3]])
Y = array([[0, 100],
[3, 500],
[6, 800]])
and would like to lookup each element of X in Y, then be able to return the second column of Y:
Z = array([[100, 500, 800],
[500, 500, 500],
[800, 100, 500]])
thanks, fahhean
We've had some good experiences building an app on Google App Engine, this first app's target audience are Google Apps users, so no issues there in terms of it being hosted on Google infrastructure.
We like it so much that we would like to investigate using it for a another app, however this next project is for a client who is not really that interested in what technology it sits on, they just want it to work, and work all of the time.
In this scenario, given that we have the technology applicability and capability side covered, are there any concerns that this stuff is still relatively new and that we may not be as much "in control" as if we had it done with traditional hosting?
I have two wxListCtrl and want to process the Ctrl+Enter keyboard event without letting wx change the focus to the other ListCtrl.
I have event handlers for wx.EVT_KEY_DOWN, wx.EVT_KEY_UP, wx.EVT_CHAR and KillFocus, but KillFocus is always called first, then the focus changes and the the keyboard handlers are called for the wrong ListCtrl.
Is there a way to prevent wx from changing the focus, when Ctrl+Enter is pressed ?
I am attempting to run a query like this:
SELECT
comment_type_id, name, count(comment_type_id)
FROM
comments, commenttypes
WHERE
comment_type_id=commenttypes.id
GROUP BY
comment_type_id
Without the join between comments and commenttypes for the name column, I can do this using:
session.query(Comment.comment_type_id,func.count(Comment.comment_type_id)).group_by(Comment.comment_type_id).all()
However, if I try to do something like this, I get incorrect results:
session.query(Comment.comment_type_id, Comment.comment_type, func.count(Comment.comment_type_id)).group_by(Comment.comment_type_id).all()
I have two problems with the results:
(1, False, 82920)
(2, False, 588)
(3, False, 4278)
(4, False, 104370)
Problems:
The False is not correct
The counts are wrong
My expected results are:
(1, 'Comment Type 1', 13820)
(2, 'Comment Type 2', 98)
(3, 'Comment Type 2', 713)
(4, 'Comment Type 2', 17395)
How can I adjust my command to pull the correct name value and the correct count?
I have a table, Foo. I run a query on Foo to get the ids from a subset of Foo. I then want to run a more complicated set of queries, but only on those IDs. Is there an efficient way to do this? The best I can think of is creating a query such as:
SELECT ... --complicated stuff
WHERE ... --more stuff
AND id IN (1, 2, 3, 9, 413, 4324, ..., 939393)
That is, I construct a huge "IN" clause. Is this efficient? Is there a more efficient way of doing this, or is the only way to JOIN with the inital query that gets the IDs? If it helps, I'm using SQLObject to connect to a PostgreSQL database, and I have access to the cursor that executed the query to get all the IDs.
The title says it all. The objective is to have two simple ways to source some code, say func.R, containing a function. Calling R CMD BATCH func.R initializes the function and evaluates is. Within a session, issuing source("func.R") simply initializes the function.
Any idea?
More specifically I'm looking for something, perhaps an add-on for firefox, once enabled it logs all of this information as it's passed to and from the server. I'm doing some web scripting and this would be really handy.
If anyone is wondering specifically what I'm doing currently I'm trying to make a script to repost my craigslist ad every 2 days since I handle a few things on there. Might even go so far as to make a simple gui to manage the submissions.
I do suspect this goes against the ToS, for that reason I don't plan to release the code. Besides cl is already bad enough with spam, I'm not trying to contribute further to it, figured I'd say what I'm doing for the sake of being honest though. I don't have any bad intentions with this, just some things I've been trying to sell an ad for my pc repair business. I've been reposting some things for months now and so often I just forget to do it.
I have a form in which I can input text through text boxes.
How do I make these data go into the db on clicking submit.
this is the code of the form in the template.
<form method="post" action="app/save_page">
<p>
Title:<input type="text" name="title"/>
</p>
<p>
Name:<input type="text" name="name"/>
</p>
<p>
Phone:<input type="text" name="phone"/>
</p>
<p>
Email:<input type="text" name="email"/>
</p>
<p>
<textarea name="description" rows=20 cols=60>
</textarea><br>
</p>
<input type="submit" value="Submit"/>
</form>
I have a function in the views.py for saving the data in the page. But I dont know how to impliment it properly:
def save_page(request):
title = request.POST["title"]
name = request.POST["name"]
phone = request.POST["phone"]
email = request.POST["email"]
description = request.POST["description"]
Now how do I send these into the db?
And what do I put in views.py so that those data goes into the db?
so how do I open a database connection and put those into the db and save it?
should I do something like :
connection=sqlite3.connect('app.db')
cursor= connection.cursor()
.....
.....
connection.commit()
connection.close()
Thank you.