Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replaced deprecated datetime.utcnow() with datetime.now() #941

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/chapter-06.rst
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,7 @@ it doesn't exist:
@action.uses(db)
def index():
client_ip = request.environ.get('REMOTE_ADDR')
db.visit_log.insert(client_ip=client_ip, timestamp=datetime.utcnow())
db.visit_log.insert(client_ip=client_ip, timestamp=datetime.now())
return "Your visit was stored in database"

Notice that the database fixture defines (creates/re-creates) tables
Expand Down
4 changes: 2 additions & 2 deletions py4web/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1168,7 +1168,7 @@ def get_error_snapshot(depth=5):
etype = etype.__name__

data = {}
data["timestamp"] = datetime.datetime.utcnow().isoformat().replace("T", " ")
data["timestamp"] = datetime.datetime.now().isoformat().replace("T", " ")
data["python_version"] = sys.version
platform_keys = [
"machine",
Expand Down Expand Up @@ -1248,7 +1248,7 @@ def log(self, app_name, error_snapshot):
app_name=app_name,
method=request.method,
path=request.path,
timestamp=datetime.datetime.utcnow(),
timestamp=datetime.datetime.now(),
client_ip=request.environ.get("REMOTE_ADDR"),
error=error_snapshot["exception_value"],
snapshot=error_snapshot,
Expand Down
6 changes: 3 additions & 3 deletions py4web/utils/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def on_request(self, context):
# record the time of the latest activity for logged in user (with throttling)
if not activity or time_now - activity > 6:
self.auth.session["recent_activity"] = time_now
self.auth.session["recent_timestamp"] = datetime.datetime.utcnow().isoformat()
self.auth.session["recent_timestamp"] = datetime.datetime.now().isoformat()
if callable(self.condition) and not self.condition(user):
self.abort_or_redirect("not-authorized", "User not authorized")

Expand Down Expand Up @@ -424,7 +424,7 @@ def define_tables(self):
@property
def signature(self):
"""Returns a list of fields for a table signature"""
now = lambda: datetime.datetime.utcnow()
now = lambda: datetime.datetime.now()
user = lambda s=self: s.user_id
fields = [
Field(
Expand Down Expand Up @@ -787,7 +787,7 @@ def change_password(
past_passwords_hash=past_pwds
)
num = db(db.auth_user.id == user.get("id")).update(
password=new_pwd, last_password_change=datetime.datetime.utcnow()
password=new_pwd, last_password_change=datetime.datetime.now()
)
return {"updated": num}

Expand Down
4 changes: 2 additions & 2 deletions py4web/utils/dbstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def __init__(self, db, name="py4web_session"):
self.table = db[name]

def get(self, key):
db, table, now = self.db, self.table, datetime.utcnow()
db, table, now = self.db, self.table, datetime.now()
row = db(table.rkey == key).select().first()
if not row:
return None
Expand All @@ -28,7 +28,7 @@ def get(self, key):
return row.rvalue

def set(self, key, value, expiration=None):
db, table, now = self.db, self.table, datetime.utcnow()
db, table, now = self.db, self.table, datetime.now()
db(table.expires_on < now).delete()
row = db(table.rkey == key).select().first()
expires_on = (
Expand Down
Loading